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

Unified Diff: chrome/browser/chromeos/attestation/platform_verification_impl.cc

Issue 1053773007: Add Platform Verification Mojo Services. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix gn build Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/attestation/platform_verification_impl.cc
diff --git a/chrome/browser/chromeos/attestation/platform_verification_impl.cc b/chrome/browser/chromeos/attestation/platform_verification_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a038289d769664f00aaabee8cbcdcdebe69d54b9
--- /dev/null
+++ b/chrome/browser/chromeos/attestation/platform_verification_impl.cc
@@ -0,0 +1,65 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/attestation/platform_verification_impl.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/web_contents.h"
+#include "third_party/mojo/src/mojo/public/cpp/bindings/interface_impl.h"
+
+namespace chromeos {
+namespace attestation {
+
+// static
+void PlatformVerificationImpl::Create(
+ content::RenderFrameHost* render_frame_host,
+ mojo::InterfaceRequest<media::interfaces::PlatformVerification> request) {
+ DVLOG(2) << __FUNCTION__;
+ DCHECK(render_frame_host);
+
+ mojo::BindToRequest(new PlatformVerificationImpl(render_frame_host),
+ &request);
+}
+
+PlatformVerificationImpl::PlatformVerificationImpl(
+ content::RenderFrameHost* render_frame_host)
+ : render_frame_host_(render_frame_host), weak_factory_(this) {
+ DCHECK(render_frame_host);
+}
+
+PlatformVerificationImpl::~PlatformVerificationImpl() {
+}
+
+void PlatformVerificationImpl::ChallengePlatform(
+ const mojo::String& service_id,
+ const mojo::String& challenge,
+ const ChallengePlatformCallback& callback) {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+
+ if (!platform_verification_flow_.get())
+ platform_verification_flow_ = new PlatformVerificationFlow();
+
+ platform_verification_flow_->ChallengePlatformKey(
+ content::WebContents::FromRenderFrameHost(render_frame_host_), service_id,
Darren Krahn 2015/05/06 19:02:40 Side note: PlatformVerification takes a WebContent
xhwang 2015/05/07 00:27:36 This is fine for now. Agreed we can probably simpl
+ challenge, base::Bind(&PlatformVerificationImpl::OnPlatformChallenged,
+ weak_factory_.GetWeakPtr(), callback));
+}
+
+void PlatformVerificationImpl::OnPlatformChallenged(
+ const ChallengePlatformCallback& callback,
+ Result result,
+ const std::string& signed_data,
+ const std::string& signature,
+ const std::string& platform_key_certificate) {
+ if (result != PlatformVerificationFlow::SUCCESS) {
+ DCHECK(signed_data.empty());
+ DCHECK(signature.empty());
+ DCHECK(platform_key_certificate.empty());
+ LOG(ERROR) << "Platform verification failed.";
Darren Krahn 2015/05/06 19:02:40 We don't need to bubble the failure status up to t
xhwang 2015/05/07 00:27:37 Done.
+ }
+
+ callback.Run(signed_data, signature, platform_key_certificate);
+}
+
+} // namespace attestation
+} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698