| 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_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/callback_forward.h" | 10 #include "base/callback_forward.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.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/attestation/attestation_constants.h" |
| 15 #include "chromeos/chromeos_export.h" | 15 #include "chromeos/chromeos_export.h" |
| 16 #include "chromeos/dbus/dbus_method_call_status.h" | 16 #include "chromeos/dbus/dbus_method_call_status.h" |
| 17 #include "third_party/cros_system_api/dbus/service_constants.h" | 17 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 18 | 18 |
| 19 class AccountId; |
| 20 |
| 19 namespace cryptohome { | 21 namespace cryptohome { |
| 20 | 22 |
| 21 class AsyncMethodCaller; | 23 class AsyncMethodCaller; |
| 22 | 24 |
| 23 } // namespace cryptohome | 25 } // namespace cryptohome |
| 24 | 26 |
| 25 namespace chromeos { | 27 namespace chromeos { |
| 26 | 28 |
| 27 class CryptohomeClient; | 29 class CryptohomeClient; |
| 28 | 30 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 64 |
| 63 // Gets an attestation certificate for a hardware-protected key. If a key for | 65 // Gets an attestation certificate for a hardware-protected key. If a key for |
| 64 // the given profile does not exist, it will be generated and a certificate | 66 // the given profile does not exist, it will be generated and a certificate |
| 65 // request will be made to the Chrome OS Privacy CA to issue a certificate for | 67 // request will be made to the Chrome OS Privacy CA to issue a certificate for |
| 66 // the key. If the key already exists and |force_new_key| is false, the | 68 // the key. If the key already exists and |force_new_key| is false, the |
| 67 // existing certificate is returned. | 69 // existing certificate is returned. |
| 68 // | 70 // |
| 69 // Parameters | 71 // Parameters |
| 70 // certificate_profile - Specifies what kind of certificate should be | 72 // certificate_profile - Specifies what kind of certificate should be |
| 71 // requested from the CA. | 73 // requested from the CA. |
| 72 // user_id - Identifies the currently active user. For normal GAIA users | 74 // account_id - Identifies the currently active user. This is ignored when |
| 73 // this is a canonical email address. This is ignored when using | 75 // using the enterprise machine cert profile. |
| 74 // the enterprise machine cert profile. | |
| 75 // request_origin - For content protection profiles, certificate requests | 76 // request_origin - For content protection profiles, certificate requests |
| 76 // are origin-specific. This string must uniquely identify | 77 // are origin-specific. This string must uniquely identify |
| 77 // the origin of the request. | 78 // the origin of the request. |
| 78 // force_new_key - If set to true, a new key will be generated even if a key | 79 // force_new_key - If set to true, a new key will be generated even if a key |
| 79 // already exists for the profile. The new key will replace | 80 // already exists for the profile. The new key will replace |
| 80 // the existing key on success. | 81 // the existing key on success. |
| 81 // callback - A callback which will be called when the operation completes. | 82 // callback - A callback which will be called when the operation completes. |
| 82 // On success |result| will be true and |data| will contain the | 83 // On success |result| will be true and |data| will contain the |
| 83 // PCA-issued certificate chain in PEM format. | 84 // PCA-issued certificate chain in PEM format. |
| 84 virtual void GetCertificate(AttestationCertificateProfile certificate_profile, | 85 virtual void GetCertificate(AttestationCertificateProfile certificate_profile, |
| 85 const std::string& user_id, | 86 const AccountId& account_id, |
| 86 const std::string& request_origin, | 87 const std::string& request_origin, |
| 87 bool force_new_key, | 88 bool force_new_key, |
| 88 const CertificateCallback& callback); | 89 const CertificateCallback& callback); |
| 89 | 90 |
| 90 private: | 91 private: |
| 91 // Asynchronously initiates the attestation enrollment flow. | 92 // Asynchronously initiates the attestation enrollment flow. |
| 92 // | 93 // |
| 93 // Parameters | 94 // Parameters |
| 94 // on_failure - Called if any failure occurs. | 95 // on_failure - Called if any failure occurs. |
| 95 // next_task - Called on successful enrollment. | 96 // next_task - Called on successful enrollment. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 const base::Closure& next_task, | 137 const base::Closure& next_task, |
| 137 bool success, | 138 bool success, |
| 138 cryptohome::MountError not_used); | 139 cryptohome::MountError not_used); |
| 139 | 140 |
| 140 // Asynchronously initiates the certificate request flow. Attestation | 141 // Asynchronously initiates the certificate request flow. Attestation |
| 141 // enrollment must complete successfully before this operation can succeed. | 142 // enrollment must complete successfully before this operation can succeed. |
| 142 // | 143 // |
| 143 // Parameters | 144 // Parameters |
| 144 // certificate_profile - Specifies what kind of certificate should be | 145 // certificate_profile - Specifies what kind of certificate should be |
| 145 // requested from the CA. | 146 // requested from the CA. |
| 146 // user_id - Identifies the active user. | 147 // account_id - Identifies the active user. |
| 147 // request_origin - An identifier for the origin of this request. | 148 // request_origin - An identifier for the origin of this request. |
| 148 // generate_new_key - If set to true a new key is generated. | 149 // generate_new_key - If set to true a new key is generated. |
| 149 // callback - Called when the operation completes. | 150 // callback - Called when the operation completes. |
| 150 void StartCertificateRequest( | 151 void StartCertificateRequest( |
| 151 const AttestationCertificateProfile certificate_profile, | 152 const AttestationCertificateProfile certificate_profile, |
| 152 const std::string& user_id, | 153 const AccountId& account_id, |
| 153 const std::string& request_origin, | 154 const std::string& request_origin, |
| 154 bool generate_new_key, | 155 bool generate_new_key, |
| 155 const CertificateCallback& callback); | 156 const CertificateCallback& callback); |
| 156 | 157 |
| 157 // Called when the attestation daemon has finished creating a certificate | 158 // Called when the attestation daemon has finished creating a certificate |
| 158 // request for the Privacy CA. The request is asynchronously forwarded as-is | 159 // request for the Privacy CA. The request is asynchronously forwarded as-is |
| 159 // to the PCA. | 160 // to the PCA. |
| 160 // | 161 // |
| 161 // Parameters | 162 // Parameters |
| 162 // key_type - The type of the key for which a certificate is requested. | 163 // key_type - The type of the key for which a certificate is requested. |
| 163 // user_id - Identifies the active user. | 164 // account_id - Identifies the active user. |
| 164 // key_name - The name of the key for which a certificate is requested. | 165 // key_name - The name of the key for which a certificate is requested. |
| 165 // callback - Called when the operation completes. | 166 // callback - Called when the operation completes. |
| 166 // success - The status of request creation. | 167 // success - The status of request creation. |
| 167 // data - The request data for the Privacy CA. | 168 // data - The request data for the Privacy CA. |
| 168 void SendCertificateRequestToPCA(AttestationKeyType key_type, | 169 void SendCertificateRequestToPCA(AttestationKeyType key_type, |
| 169 const std::string& user_id, | 170 const AccountId& account_id, |
| 170 const std::string& key_name, | 171 const std::string& key_name, |
| 171 const CertificateCallback& callback, | 172 const CertificateCallback& callback, |
| 172 bool success, | 173 bool success, |
| 173 const std::string& data); | 174 const std::string& data); |
| 174 | 175 |
| 175 // Called when the Privacy CA responds to a certificate request. The response | 176 // Called when the Privacy CA responds to a certificate request. The response |
| 176 // is asynchronously forwarded as-is to the attestation daemon in order to | 177 // is asynchronously forwarded as-is to the attestation daemon in order to |
| 177 // complete the operation. | 178 // complete the operation. |
| 178 // | 179 // |
| 179 // Parameters | 180 // Parameters |
| 180 // key_type - The type of the key for which a certificate is requested. | 181 // key_type - The type of the key for which a certificate is requested. |
| 181 // user_id - Identifies the active user. | 182 // account_id - Identifies the active user. |
| 182 // key_name - The name of the key for which a certificate is requested. | 183 // key_name - The name of the key for which a certificate is requested. |
| 183 // callback - Called when the operation completes. | 184 // callback - Called when the operation completes. |
| 184 // success - The status of the Privacy CA operation. | 185 // success - The status of the Privacy CA operation. |
| 185 // data - The response data from the Privacy CA. | 186 // data - The response data from the Privacy CA. |
| 186 void SendCertificateResponseToDaemon(AttestationKeyType key_type, | 187 void SendCertificateResponseToDaemon(AttestationKeyType key_type, |
| 187 const std::string& user_id, | 188 const AccountId& account_id, |
| 188 const std::string& key_name, | 189 const std::string& key_name, |
| 189 const CertificateCallback& callback, | 190 const CertificateCallback& callback, |
| 190 bool success, | 191 bool success, |
| 191 const std::string& data); | 192 const std::string& data); |
| 192 | 193 |
| 193 // Gets an existing certificate from the attestation daemon. | 194 // Gets an existing certificate from the attestation daemon. |
| 194 // | 195 // |
| 195 // Parameters | 196 // Parameters |
| 196 // key_type - The type of the key for which a certificate is requested. | 197 // key_type - The type of the key for which a certificate is requested. |
| 197 // user_id - Identifies the active user. | 198 // account_id - Identifies the active user. |
| 198 // key_name - The name of the key for which a certificate is requested. | 199 // key_name - The name of the key for which a certificate is requested. |
| 199 // callback - Called when the operation completes. | 200 // callback - Called when the operation completes. |
| 200 void GetExistingCertificate(AttestationKeyType key_type, | 201 void GetExistingCertificate(AttestationKeyType key_type, |
| 201 const std::string& user_id, | 202 const AccountId& account_id, |
| 202 const std::string& key_name, | 203 const std::string& key_name, |
| 203 const CertificateCallback& callback); | 204 const CertificateCallback& callback); |
| 204 | 205 |
| 205 cryptohome::AsyncMethodCaller* async_caller_; | 206 cryptohome::AsyncMethodCaller* async_caller_; |
| 206 CryptohomeClient* cryptohome_client_; | 207 CryptohomeClient* cryptohome_client_; |
| 207 scoped_ptr<ServerProxy> server_proxy_; | 208 scoped_ptr<ServerProxy> server_proxy_; |
| 208 | 209 |
| 209 base::WeakPtrFactory<AttestationFlow> weak_factory_; | 210 base::WeakPtrFactory<AttestationFlow> weak_factory_; |
| 210 | 211 |
| 211 DISALLOW_COPY_AND_ASSIGN(AttestationFlow); | 212 DISALLOW_COPY_AND_ASSIGN(AttestationFlow); |
| 212 }; | 213 }; |
| 213 | 214 |
| 214 } // namespace attestation | 215 } // namespace attestation |
| 215 } // namespace chromeos | 216 } // namespace chromeos |
| 216 | 217 |
| 217 #endif // CHROMEOS_ATTESTATION_ATTESTATION_FLOW_H_ | 218 #endif // CHROMEOS_ATTESTATION_ATTESTATION_FLOW_H_ |
| OLD | NEW |