OLD | NEW |
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_DBUS_CRYPTOHOME_CLIENT_H_ | 5 #ifndef CHROMEOS_DBUS_CRYPTOHOME_CLIENT_H_ |
6 #define CHROMEOS_DBUS_CRYPTOHOME_CLIENT_H_ | 6 #define CHROMEOS_DBUS_CRYPTOHOME_CLIENT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "chromeos/attestation/attestation_constants.h" |
13 #include "chromeos/chromeos_export.h" | 14 #include "chromeos/chromeos_export.h" |
14 #include "chromeos/dbus/dbus_client_implementation_type.h" | 15 #include "chromeos/dbus/dbus_client_implementation_type.h" |
15 #include "chromeos/dbus/dbus_method_call_status.h" | 16 #include "chromeos/dbus/dbus_method_call_status.h" |
16 | 17 |
17 namespace dbus { | 18 namespace dbus { |
18 class Bus; | 19 class Bus; |
19 } | 20 } |
20 | 21 |
21 namespace chromeos { | 22 namespace chromeos { |
22 | 23 |
(...skipping 17 matching lines...) Expand all Loading... |
40 // A callback to handle responses of Pkcs11GetTpmTokenInfo method. | 41 // A callback to handle responses of Pkcs11GetTpmTokenInfo method. |
41 typedef base::Callback<void( | 42 typedef base::Callback<void( |
42 DBusMethodCallStatus call_status, | 43 DBusMethodCallStatus call_status, |
43 const std::string& label, | 44 const std::string& label, |
44 const std::string& user_pin)> Pkcs11GetTpmTokenInfoCallback; | 45 const std::string& user_pin)> Pkcs11GetTpmTokenInfoCallback; |
45 // A callback for methods which return both a bool result and data. | 46 // A callback for methods which return both a bool result and data. |
46 typedef base::Callback<void(DBusMethodCallStatus call_status, | 47 typedef base::Callback<void(DBusMethodCallStatus call_status, |
47 bool result, | 48 bool result, |
48 const std::string& data)> DataMethodCallback; | 49 const std::string& data)> DataMethodCallback; |
49 | 50 |
50 // Options available for customizing an attestation certificate. | |
51 enum AttestationCertificateOptions { | |
52 CERTIFICATE_OPTION_NONE = 0, | |
53 INCLUDE_STABLE_ID = 1, | |
54 INCLUDE_DEVICE_STATE = 1 << 1 | |
55 }; | |
56 | |
57 // Key types supported by the Chrome OS attestation subsystem. | |
58 enum AttestationKeyType { | |
59 DEVICE_KEY, | |
60 USER_KEY | |
61 }; | |
62 | |
63 // Options available for customizing an attestation challenge response. | |
64 enum AttestationChallengeOptions { | |
65 CHALLENGE_RESPONSE_OPTION_NONE = 0, | |
66 INCLUDE_SIGNED_PUBLIC_KEY = 1 | |
67 }; | |
68 | |
69 virtual ~CryptohomeClient(); | 51 virtual ~CryptohomeClient(); |
70 | 52 |
71 // Factory function, creates a new instance and returns ownership. | 53 // Factory function, creates a new instance and returns ownership. |
72 // For normal usage, access the singleton via DBusThreadManager::Get(). | 54 // For normal usage, access the singleton via DBusThreadManager::Get(). |
73 static CryptohomeClient* Create(DBusClientImplementationType type, | 55 static CryptohomeClient* Create(DBusClientImplementationType type, |
74 dbus::Bus* bus); | 56 dbus::Bus* bus); |
75 | 57 |
76 // Sets AsyncCallStatus signal handlers. | 58 // Sets AsyncCallStatus signal handlers. |
77 // |handler| is called when results for AsyncXXX methods are returned. | 59 // |handler| is called when results for AsyncXXX methods are returned. |
78 // Cryptohome service will process the calls in a first-in-first-out manner | 60 // Cryptohome service will process the calls in a first-in-first-out manner |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 234 |
253 // Asynchronously finishes a certificate request operation. The callback will | 235 // Asynchronously finishes a certificate request operation. The callback will |
254 // be called when the dbus call completes. When the operation completes, the | 236 // be called when the dbus call completes. When the operation completes, the |
255 // AsyncCallStatusWithDataHandler signal handler is called. The data that is | 237 // AsyncCallStatusWithDataHandler signal handler is called. The data that is |
256 // sent with the signal is a certificate chain in PEM format. |pca_response| | 238 // sent with the signal is a certificate chain in PEM format. |pca_response| |
257 // is the response to the certificate request emitted by the Privacy CA. | 239 // is the response to the certificate request emitted by the Privacy CA. |
258 // |key_type| determines whether the certified key is to be associated with | 240 // |key_type| determines whether the certified key is to be associated with |
259 // the current user. |key_name| is a name for the key. | 241 // the current user. |key_name| is a name for the key. |
260 virtual void AsyncTpmAttestationFinishCertRequest( | 242 virtual void AsyncTpmAttestationFinishCertRequest( |
261 const std::string& pca_response, | 243 const std::string& pca_response, |
262 AttestationKeyType key_type, | 244 attestation::AttestationKeyType key_type, |
263 const std::string& key_name, | 245 const std::string& key_name, |
264 const AsyncMethodCallback& callback) = 0; | 246 const AsyncMethodCallback& callback) = 0; |
265 | 247 |
266 // Checks if an attestation key already exists. If the key specified by | 248 // Checks if an attestation key already exists. If the key specified by |
267 // |key_type| and |key_name| exists, then the result sent to the callback will | 249 // |key_type| and |key_name| exists, then the result sent to the callback will |
268 // be true. | 250 // be true. |
269 virtual void TpmAttestationDoesKeyExist( | 251 virtual void TpmAttestationDoesKeyExist( |
270 AttestationKeyType key_type, | 252 attestation::AttestationKeyType key_type, |
271 const std::string& key_name, | 253 const std::string& key_name, |
272 const BoolDBusMethodCallback& callback) = 0; | 254 const BoolDBusMethodCallback& callback) = 0; |
273 | 255 |
274 // Gets the attestation certificate for the key specified by |key_type| and | 256 // Gets the attestation certificate for the key specified by |key_type| and |
275 // |key_name|. |callback| will be called when the operation completes. If | 257 // |key_name|. |callback| will be called when the operation completes. If |
276 // the key does not exist the callback |result| parameter will be false. | 258 // the key does not exist the callback |result| parameter will be false. |
277 virtual void TpmAttestationGetCertificate( | 259 virtual void TpmAttestationGetCertificate( |
278 AttestationKeyType key_type, | 260 attestation::AttestationKeyType key_type, |
279 const std::string& key_name, | 261 const std::string& key_name, |
280 const DataMethodCallback& callback) = 0; | 262 const DataMethodCallback& callback) = 0; |
281 | 263 |
282 // Gets the public key for the key specified by |key_type| and |key_name|. | 264 // Gets the public key for the key specified by |key_type| and |key_name|. |
283 // |callback| will be called when the operation completes. If the key does | 265 // |callback| will be called when the operation completes. If the key does |
284 // not exist the callback |result| parameter will be false. | 266 // not exist the callback |result| parameter will be false. |
285 virtual void TpmAttestationGetPublicKey( | 267 virtual void TpmAttestationGetPublicKey( |
286 AttestationKeyType key_type, | 268 attestation::AttestationKeyType key_type, |
287 const std::string& key_name, | 269 const std::string& key_name, |
288 const DataMethodCallback& callback) = 0; | 270 const DataMethodCallback& callback) = 0; |
289 | 271 |
290 // Asynchronously registers an attestation key with the current user's | 272 // Asynchronously registers an attestation key with the current user's |
291 // PKCS #11 token. The |callback| will be called when the dbus call | 273 // PKCS #11 token. The |callback| will be called when the dbus call |
292 // completes. When the operation completes, the AsyncCallStatusHandler signal | 274 // completes. When the operation completes, the AsyncCallStatusHandler signal |
293 // handler is called. |key_type| and |key_name| specify the key to register. | 275 // handler is called. |key_type| and |key_name| specify the key to register. |
294 virtual void TpmAttestationRegisterKey( | 276 virtual void TpmAttestationRegisterKey( |
295 AttestationKeyType key_type, | 277 attestation::AttestationKeyType key_type, |
296 const std::string& key_name, | 278 const std::string& key_name, |
297 const AsyncMethodCallback& callback) = 0; | 279 const AsyncMethodCallback& callback) = 0; |
298 | 280 |
299 // Asynchronously signs an enterprise challenge with the key specified by | 281 // Asynchronously signs an enterprise challenge with the key specified by |
300 // |key_type| and |key_name|. |domain| and |device_id| will be included in | 282 // |key_type| and |key_name|. |domain| and |device_id| will be included in |
301 // the challenge response. |options| control how the challenge response is | 283 // the challenge response. |options| control how the challenge response is |
302 // generated. |challenge| must be a valid enterprise attestation challenge. | 284 // generated. |challenge| must be a valid enterprise attestation challenge. |
303 // The |callback| will be called when the dbus call completes. When the | 285 // The |callback| will be called when the dbus call completes. When the |
304 // operation completes, the AsyncCallStatusWithDataHandler signal handler is | 286 // operation completes, the AsyncCallStatusWithDataHandler signal handler is |
305 // called. | 287 // called. |
306 virtual void TpmAttestationSignEnterpriseChallenge( | 288 virtual void TpmAttestationSignEnterpriseChallenge( |
307 AttestationKeyType key_type, | 289 attestation::AttestationKeyType key_type, |
308 const std::string& key_name, | 290 const std::string& key_name, |
309 const std::string& domain, | 291 const std::string& domain, |
310 const std::string& device_id, | 292 const std::string& device_id, |
311 AttestationChallengeOptions options, | 293 attestation::AttestationChallengeOptions options, |
312 const std::string& challenge, | 294 const std::string& challenge, |
313 const AsyncMethodCallback& callback) = 0; | 295 const AsyncMethodCallback& callback) = 0; |
314 | 296 |
315 // Asynchronously signs a simple challenge with the key specified by | 297 // Asynchronously signs a simple challenge with the key specified by |
316 // |key_type| and |key_name|. |challenge| can be any set of arbitrary bytes. | 298 // |key_type| and |key_name|. |challenge| can be any set of arbitrary bytes. |
317 // A nonce will be appended to the challenge before signing; this method | 299 // A nonce will be appended to the challenge before signing; this method |
318 // cannot be used to sign arbitrary data. The |callback| will be called when | 300 // cannot be used to sign arbitrary data. The |callback| will be called when |
319 // the dbus call completes. When the operation completes, the | 301 // the dbus call completes. When the operation completes, the |
320 // AsyncCallStatusWithDataHandler signal handler is called. | 302 // AsyncCallStatusWithDataHandler signal handler is called. |
321 virtual void TpmAttestationSignSimpleChallenge( | 303 virtual void TpmAttestationSignSimpleChallenge( |
322 AttestationKeyType key_type, | 304 attestation::AttestationKeyType key_type, |
323 const std::string& key_name, | 305 const std::string& key_name, |
324 const std::string& challenge, | 306 const std::string& challenge, |
325 const AsyncMethodCallback& callback) = 0; | 307 const AsyncMethodCallback& callback) = 0; |
326 | 308 |
327 // Gets the payload associated with the key specified by |key_type| and | 309 // Gets the payload associated with the key specified by |key_type| and |
328 // |key_name|. The |callback| will be called when the operation completes. | 310 // |key_name|. The |callback| will be called when the operation completes. |
329 // If the key does not exist the callback |result| parameter will be false. | 311 // If the key does not exist the callback |result| parameter will be false. |
330 // If no payload has been set for the key the callback |result| parameter will | 312 // If no payload has been set for the key the callback |result| parameter will |
331 // be true and the |data| parameter will be empty. | 313 // be true and the |data| parameter will be empty. |
332 virtual void TpmAttestationGetKeyPayload( | 314 virtual void TpmAttestationGetKeyPayload( |
333 AttestationKeyType key_type, | 315 attestation::AttestationKeyType key_type, |
334 const std::string& key_name, | 316 const std::string& key_name, |
335 const DataMethodCallback& callback) = 0; | 317 const DataMethodCallback& callback) = 0; |
336 | 318 |
337 // Sets the |payload| associated with the key specified by |key_type| and | 319 // Sets the |payload| associated with the key specified by |key_type| and |
338 // |key_name|. The |callback| will be called when the operation completes. | 320 // |key_name|. The |callback| will be called when the operation completes. |
339 // If the operation succeeds, the callback |result| parameter will be true. | 321 // If the operation succeeds, the callback |result| parameter will be true. |
340 virtual void TpmAttestationSetKeyPayload( | 322 virtual void TpmAttestationSetKeyPayload( |
341 AttestationKeyType key_type, | 323 attestation::AttestationKeyType key_type, |
342 const std::string& key_name, | 324 const std::string& key_name, |
343 const std::string& payload, | 325 const std::string& payload, |
344 const BoolDBusMethodCallback& callback) = 0; | 326 const BoolDBusMethodCallback& callback) = 0; |
345 | 327 |
346 protected: | 328 protected: |
347 // Create() should be used instead. | 329 // Create() should be used instead. |
348 CryptohomeClient(); | 330 CryptohomeClient(); |
349 | 331 |
350 private: | 332 private: |
351 DISALLOW_COPY_AND_ASSIGN(CryptohomeClient); | 333 DISALLOW_COPY_AND_ASSIGN(CryptohomeClient); |
352 }; | 334 }; |
353 | 335 |
354 } // namespace chromeos | 336 } // namespace chromeos |
355 | 337 |
356 #endif // CHROMEOS_DBUS_CRYPTOHOME_CLIENT_H_ | 338 #endif // CHROMEOS_DBUS_CRYPTOHOME_CLIENT_H_ |
OLD | NEW |