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

Side by Side Diff: chromeos/attestation/attestation_flow.h

Issue 14305009: Enhanced and refactored the AttestationFlow interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 #ifndef CHROMEOS_ATTESTATION_ATTESTATION_FLOW_H_ 5 #ifndef CHROMEOS_ATTESTATION_ATTESTATION_FLOW_H_
6 #define CHROMEOS_ATTESTATION_ATTESTATION_FLOW_H_ 6 #define CHROMEOS_ATTESTATION_ATTESTATION_FLOW_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "chromeos/attestation/attestation_constants.h"
14 #include "chromeos/chromeos_export.h" 15 #include "chromeos/chromeos_export.h"
15 #include "chromeos/dbus/dbus_method_call_status.h" 16 #include "chromeos/dbus/dbus_method_call_status.h"
16 #include "third_party/cros_system_api/dbus/service_constants.h" 17 #include "third_party/cros_system_api/dbus/service_constants.h"
17 18
18 namespace cryptohome { 19 namespace cryptohome {
19 20
20 class AsyncMethodCaller; 21 class AsyncMethodCaller;
21 22
22 } // namespace cryptohome 23 } // namespace cryptohome
23 24
(...skipping 10 matching lines...) Expand all
34 const std::string& data)> DataCallback; 35 const std::string& data)> DataCallback;
35 virtual ~ServerProxy() {} 36 virtual ~ServerProxy() {}
36 virtual void SendEnrollRequest(const std::string& request, 37 virtual void SendEnrollRequest(const std::string& request,
37 const DataCallback& on_response) = 0; 38 const DataCallback& on_response) = 0;
38 virtual void SendCertificateRequest(const std::string& request, 39 virtual void SendCertificateRequest(const std::string& request,
39 const DataCallback& on_response) = 0; 40 const DataCallback& on_response) = 0;
40 }; 41 };
41 42
42 // Implements the message flow for Chrome OS attestation tasks. Generally this 43 // Implements the message flow for Chrome OS attestation tasks. Generally this
43 // consists of coordinating messages between the Chrome OS attestation service 44 // consists of coordinating messages between the Chrome OS attestation service
44 // and the Privacy CA server. Sample usage: 45 // and the Chrome OS Privacy CA server. Sample usage:
45 // AttestationFlow flow(AsyncMethodCaller::GetInstance(), 46 // AttestationFlow flow(AsyncMethodCaller::GetInstance(),
46 // DBusThreadManager::Get().GetCryptohomeClient(), 47 // DBusThreadManager::Get().GetCryptohomeClient(),
47 // my_server_proxy); 48 // my_server_proxy.Pass());
48 // CertificateCallback callback = base::Bind(&MyCallback); 49 // AttestationFlow::CertificateCallback callback = base::Bind(&MyCallback);
49 // flow.GetCertificate("attest-ent-machine", callback); 50 // flow.GetCertificate(ENTERPRISE_USER_CERTIFICATE, false, callback);
50 class CHROMEOS_EXPORT AttestationFlow { 51 class CHROMEOS_EXPORT AttestationFlow {
51 public: 52 public:
52 typedef base::Callback<void(bool success, 53 typedef base::Callback<void(bool success,
53 const std::string& pem_certificate_chain)> 54 const std::string& pem_certificate_chain)>
54 CertificateCallback; 55 CertificateCallback;
55 56
56 AttestationFlow(cryptohome::AsyncMethodCaller* async_caller, 57 AttestationFlow(cryptohome::AsyncMethodCaller* async_caller,
57 CryptohomeClient* cryptohome_client, 58 CryptohomeClient* cryptohome_client,
58 scoped_ptr<ServerProxy> server_proxy); 59 scoped_ptr<ServerProxy> server_proxy);
59 virtual ~AttestationFlow(); 60 virtual ~AttestationFlow();
60 61
61 // Asynchronously gets an attestation certificate bound to the given name. 62 // Gets an attestation certificate for a hardware-protected key. If a key for
62 // If no certificate has been associated with the name, a new certificate is 63 // the given profile does not exist, it will be generated and a certificate
63 // issued. 64 // request will be made to the Chrome OS Privacy CA to issue a certificate for
65 // the key. If the key already exists and |force_new_key| is false, the
66 // existing certificate is returned.
64 // 67 //
65 // Parameters 68 // Parameters
66 // name - The name of the key for which to retrieve a certificate. The 69 // certificate_profile - Specifies what kind of certificate should be
67 // following key names are available: 70 // requested from the CA.
68 // "attest-ent-machine" - The enterprise machine key. 71 // force_new_key - If set to true, a new key will be generated even if a key
69 // "attest-ent-user" - An enterprise user key for the current user. 72 // already exists for the profile. The new key will replace
70 // "content-[origin]" - A content protection key bound to a 73 // the existing key on success.
71 // specific origin for the current user.
72 // callback - A callback which will be called when the operation completes. 74 // callback - A callback which will be called when the operation completes.
73 virtual void GetCertificate(const std::string& name, 75 // On success |result| will be true and |data| will contain the
76 // PCA-issued certificate chain in PEM format.
77 virtual void GetCertificate(AttestationCertificateProfile certificate_profile,
78 bool force_new_key,
74 const CertificateCallback& callback); 79 const CertificateCallback& callback);
75 80
76 private: 81 private:
77 // The key name defined for the special-purpose Enterprise Machine Key.
78 static const char kEnterpriseMachineKey[];
79
80 // Asynchronously initiates the attestation enrollment flow. 82 // Asynchronously initiates the attestation enrollment flow.
81 // 83 //
82 // Parameters 84 // Parameters
83 // on_failure - Called if any failure occurs. 85 // on_failure - Called if any failure occurs.
84 // next_task - Called on successful enrollment. 86 // next_task - Called on successful enrollment.
85 void StartEnroll(const base::Closure& on_failure, 87 void StartEnroll(const base::Closure& on_failure,
86 const base::Closure& next_task); 88 const base::Closure& next_task);
87 89
88 // Called when the attestation daemon has finished creating an enrollment 90 // Called when the attestation daemon has finished creating an enrollment
89 // request for the Privacy CA. The request is asynchronously forwarded as-is 91 // request for the Privacy CA. The request is asynchronously forwarded as-is
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // not_used - An artifact of the cryptohome D-Bus interface; ignored. 125 // not_used - An artifact of the cryptohome D-Bus interface; ignored.
124 void OnEnrollComplete(const base::Closure& on_failure, 126 void OnEnrollComplete(const base::Closure& on_failure,
125 const base::Closure& next_task, 127 const base::Closure& next_task,
126 bool success, 128 bool success,
127 cryptohome::MountError not_used); 129 cryptohome::MountError not_used);
128 130
129 // Asynchronously initiates the certificate request flow. Attestation 131 // Asynchronously initiates the certificate request flow. Attestation
130 // enrollment must complete successfully before this operation can succeed. 132 // enrollment must complete successfully before this operation can succeed.
131 // 133 //
132 // Parameters 134 // Parameters
133 // name - The name of the key for which a certificate is requested. 135 // certificate_profile - Specifies what kind of certificate should be
136 // requested from the CA.
137 // generate_new_key - If set to true a new key is generated.
134 // callback - Called when the operation completes. 138 // callback - Called when the operation completes.
135 void StartCertificateRequest(const std::string& name, 139 void StartCertificateRequest(
136 const CertificateCallback& callback); 140 const AttestationCertificateProfile certificate_profile,
141 bool generate_new_key,
142 const CertificateCallback& callback);
137 143
138 // Called when the attestation daemon has finished creating a certificate 144 // Called when the attestation daemon has finished creating a certificate
139 // request for the Privacy CA. The request is asynchronously forwarded as-is 145 // request for the Privacy CA. The request is asynchronously forwarded as-is
140 // to the PCA. 146 // to the PCA.
141 // 147 //
142 // Parameters 148 // Parameters
143 // name - The name of the key for which a certificate is requested. 149 // key_type - The type of the key for which a certificate is requested.
150 // key_name - The name of the key for which a certificate is requested.
144 // callback - Called when the operation completes. 151 // callback - Called when the operation completes.
145 // success - The status of request creation. 152 // success - The status of request creation.
146 // data - The request data for the Privacy CA. 153 // data - The request data for the Privacy CA.
147 void SendCertificateRequestToPCA(const std::string& name, 154 void SendCertificateRequestToPCA(AttestationKeyType key_type,
155 const std::string& key_name,
148 const CertificateCallback& callback, 156 const CertificateCallback& callback,
149 bool success, 157 bool success,
150 const std::string& data); 158 const std::string& data);
151 159
152 // Called when the Privacy CA responds to a certificate request. The response 160 // Called when the Privacy CA responds to a certificate request. The response
153 // is asynchronously forwarded as-is to the attestation daemon in order to 161 // is asynchronously forwarded as-is to the attestation daemon in order to
154 // complete the operation. 162 // complete the operation.
155 // 163 //
156 // Parameters 164 // Parameters
157 // name - The name of the key for which a certificate is requested. 165 // key_type - The type of the key for which a certificate is requested.
166 // key_name - The name of the key for which a certificate is requested.
158 // callback - Called when the operation completes. 167 // callback - Called when the operation completes.
159 // success - The status of the Privacy CA operation. 168 // success - The status of the Privacy CA operation.
160 // data - The response data from the Privacy CA. 169 // data - The response data from the Privacy CA.
161 void SendCertificateResponseToDaemon(const std::string& name, 170 void SendCertificateResponseToDaemon(AttestationKeyType key_type,
171 const std::string& key_name,
162 const CertificateCallback& callback, 172 const CertificateCallback& callback,
163 bool success, 173 bool success,
164 const std::string& data); 174 const std::string& data);
165 175
166 base::WeakPtrFactory<AttestationFlow> weak_factory_; 176 // Gets an existing certificate from the attestation daemon.
177 //
178 // Parameters
179 // key_type - The type of the key for which a certificate is requested.
180 // key_name - The name of the key for which a certificate is requested.
181 // callback - Called when the operation completes.
182 void GetExistingCertificate(AttestationKeyType key_type,
183 const std::string& key_name,
184 const CertificateCallback& callback);
185
186 // Returns a key type for the given profile.
187 AttestationKeyType GetKeyTypeForProfile(
188 AttestationCertificateProfile profile);
189
190 // Returns a key name for the given profile.
191 std::string GetKeyNameForProfile(AttestationCertificateProfile profile);
192
193 // Returns a combination of certificate options for the given profile.
194 int GetCertificateOptionsForProfile(AttestationCertificateProfile profile);
195
Mattias Nissler (ping if slow) 2013/04/24 12:57:53 remove extra blank line
dkrahn 2013/04/25 01:06:52 Done.
196
167 cryptohome::AsyncMethodCaller* async_caller_; 197 cryptohome::AsyncMethodCaller* async_caller_;
168 CryptohomeClient* cryptohome_client_; 198 CryptohomeClient* cryptohome_client_;
169 scoped_ptr<ServerProxy> server_proxy_; 199 scoped_ptr<ServerProxy> server_proxy_;
170 200
201 base::WeakPtrFactory<AttestationFlow> weak_factory_;
202
171 DISALLOW_COPY_AND_ASSIGN(AttestationFlow); 203 DISALLOW_COPY_AND_ASSIGN(AttestationFlow);
172 }; 204 };
173 205
174 } // namespace attestation 206 } // namespace attestation
175 } // namespace chromeos 207 } // namespace chromeos
176 208
177 #endif // CHROMEOS_ATTESTATION_ATTESTATION_FLOW_H_ 209 #endif // CHROMEOS_ATTESTATION_ATTESTATION_FLOW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698