Skip to content

Commit

Permalink
Update Platform Verification Pepper API to request Storage ID
Browse files Browse the repository at this point in the history
In order to enable offline licenses, the CDM needs a Storage ID that will be
used to encrypt the license files saved. The CL updates the Platform
Verification Pepper API to add the messages to retrieve the Storage ID from
the browser process.

Actual implementation of the Storage ID value in progress.

BUG=478960
TEST=new browser_test passes

Change-Id: I27250418b298a3bd071c7b8c3f6dc2d150d35b77
Reviewed-on: https://chromium-review.googlesource.com/531915
Commit-Queue: John Rummell <jrummell@chromium.org>
Reviewed-by: Bill Budge <bbudge@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Xiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#485745}
  • Loading branch information
jrummell-chromium authored and Commit Bot committed Jul 12, 2017
1 parent 0f04bcb commit dc89b14
Show file tree
Hide file tree
Showing 18 changed files with 190 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ int32_t PepperPlatformVerificationMessageFilter::OnResourceMessageReceived(
PPAPI_DISPATCH_HOST_RESOURCE_CALL(
PpapiHostMsg_PlatformVerification_ChallengePlatform,
OnChallengePlatform)
PPAPI_DISPATCH_HOST_RESOURCE_CALL(
PpapiHostMsg_PlatformVerification_GetStorageId, OnGetStorageId)
PPAPI_END_MESSAGE_MAP()

return PP_ERROR_FAILED;
Expand Down Expand Up @@ -111,4 +113,16 @@ void PepperPlatformVerificationMessageFilter::ChallengePlatformCallback(
}
#endif

int32_t PepperPlatformVerificationMessageFilter::OnGetStorageId(
ppapi::host::HostMessageContext* context) {
// TODO(jrummell): Implement Storage ID. For now simply returns empty string.
// http://crbug.com/478960.
ppapi::host::ReplyMessageContext reply_context =
context->MakeReplyMessageContext();
reply_context.params.set_result(PP_OK);
SendReply(reply_context,
PpapiHostMsg_PlatformVerification_GetStorageIdReply(std::string()));
return PP_OK_COMPLETIONPENDING;
}

} // namespace chrome
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class PepperPlatformVerificationMessageFilter
const std::string& platform_key_certificate);
#endif

int32_t OnGetStorageId(ppapi::host::HostMessageContext* context);

// Used to lookup the WebContents associated with this PP_Instance.
int render_process_id_;
int render_frame_id_;
Expand Down
14 changes: 9 additions & 5 deletions chrome/test/ppapi/ppapi_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1238,11 +1238,15 @@ TEST_PPAPI_OUT_OF_PROCESS(MAYBE_FlashFullscreen)

TEST_PPAPI_OUT_OF_PROCESS(PDF)

// TODO(dalecurtis): Renable once the platform verification infobar has been
// implemented; see http://crbug.com/270908
// #if defined(OS_CHROMEOS)
// TEST_PPAPI_OUT_OF_PROCESS(PlatformVerificationPrivate)
// #endif
IN_PROC_BROWSER_TEST_F(OutOfProcessPPAPITest, PlatformVerificationPrivate) {
RunTest(
#if defined(OS_CHROMEOS)
// TODO(dalecurtis): Renable once the platform verification infobar has
// been implemented; see http://crbug.com/270908
// LIST_TEST(PlatformVerificationPrivate_ChallengePlatform)
#endif
LIST_TEST(PlatformVerificationPrivate_StorageId));
}

IN_PROC_BROWSER_TEST_F(OutOfProcessPPAPITest, FlashDRM) {
RunTest(
Expand Down
19 changes: 18 additions & 1 deletion ppapi/api/private/ppb_platform_verification_private.idl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[generate_thunk]

label Chrome {
M32 = 0.2
M61 = 0.3
};

/**
Expand Down Expand Up @@ -82,4 +82,21 @@ interface PPB_PlatformVerification_Private {
[out] PP_Var signed_data_signature,
[out] PP_Var platform_key_certificate,
[in] PP_CompletionCallback callback);

/**
* Requests the device's storage ID.
*
* @param[out] storage_id A <code>PP_Var</code> of type
* <code>PP_VARTYPE_STRING</code> that contains the storage ID.
*
* @param[in] callback A <code>PP_CompletionCallback</code> to be called after
* the storage ID has been obtained. This callback will only run if
* the return code is <code>PP_OK_COMPLETIONPENDING</code>.
*
* @return An int32_t containing an error code from <code>pp_errors.h</code>.
*/
int32_t GetStorageId(
[in] PP_Resource instance,
[out] PP_Var storage_id,
[in] PP_CompletionCallback callback);
};
4 changes: 2 additions & 2 deletions ppapi/c/pp_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
* found in the LICENSE file.
*/

/* From pp_macros.idl modified Tue Apr 4 15:29:47 2017. */
/* From pp_macros.idl modified Fri Oct 9 11:08:46 2015. */

#ifndef PPAPI_C_PP_MACROS_H_
#define PPAPI_C_PP_MACROS_H_


#define PPAPI_RELEASE 60
#define PPAPI_RELEASE 61

/**
* @file
Expand Down
27 changes: 21 additions & 6 deletions ppapi/c/private/ppb_platform_verification_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

/* From private/ppb_platform_verification_private.idl,
* modified Fri Oct 18 15:02:09 2013.
* modified Tue Jun 13 15:47:24 2017.
*/

#ifndef PPAPI_C_PRIVATE_PPB_PLATFORM_VERIFICATION_PRIVATE_H_
Expand All @@ -18,10 +18,10 @@
#include "ppapi/c/pp_stdint.h"
#include "ppapi/c/pp_var.h"

#define PPB_PLATFORMVERIFICATION_PRIVATE_INTERFACE_0_2 \
"PPB_PlatformVerification_Private;0.2"
#define PPB_PLATFORMVERIFICATION_PRIVATE_INTERFACE_0_3 \
"PPB_PlatformVerification_Private;0.3"
#define PPB_PLATFORMVERIFICATION_PRIVATE_INTERFACE \
PPB_PLATFORMVERIFICATION_PRIVATE_INTERFACE_0_2
PPB_PLATFORMVERIFICATION_PRIVATE_INTERFACE_0_3

/**
* @file
Expand All @@ -39,7 +39,7 @@
* services to verify that the underlying platform is trusted. An example of a
* trusted platform is a Chrome OS device in verified boot mode.
*/
struct PPB_PlatformVerification_Private_0_2 {
struct PPB_PlatformVerification_Private_0_3 {
/**
* Create() creates a <code>PPB_PlatformVerification_Private</code> object.
*
Expand Down Expand Up @@ -98,9 +98,24 @@ struct PPB_PlatformVerification_Private_0_2 {
struct PP_Var* signed_data_signature,
struct PP_Var* platform_key_certificate,
struct PP_CompletionCallback callback);
/**
* Requests the device's storage ID.
*
* @param[out] storage_id A <code>PP_Var</code> of type
* <code>PP_VARTYPE_STRING</code> that contains the storage ID.
*
* @param[in] callback A <code>PP_CompletionCallback</code> to be called after
* the storage ID has been obtained. This callback will only run if
* the return code is <code>PP_OK_COMPLETIONPENDING</code>.
*
* @return An int32_t containing an error code from <code>pp_errors.h</code>.
*/
int32_t (*GetStorageId)(PP_Resource instance,
struct PP_Var* storage_id,
struct PP_CompletionCallback callback);
};

typedef struct PPB_PlatformVerification_Private_0_2
typedef struct PPB_PlatformVerification_Private_0_3
PPB_PlatformVerification_Private;
/**
* @}
Expand Down
21 changes: 16 additions & 5 deletions ppapi/cpp/private/platform_verification.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ namespace pp {

namespace {

template <> const char* interface_name<PPB_PlatformVerification_Private_0_2>() {
return PPB_PLATFORMVERIFICATION_PRIVATE_INTERFACE_0_2;
template <>
const char* interface_name<PPB_PlatformVerification_Private_0_3>() {
return PPB_PLATFORMVERIFICATION_PRIVATE_INTERFACE_0_3;
}

inline bool HasInterface() {
return has_interface<PPB_PlatformVerification_Private_0_2>();
return has_interface<PPB_PlatformVerification_Private_0_3>();
}

inline const PPB_PlatformVerification_Private_0_2* GetInterface() {
return get_interface<PPB_PlatformVerification_Private_0_2>();
inline const PPB_PlatformVerification_Private_0_3* GetInterface() {
return get_interface<PPB_PlatformVerification_Private_0_3>();
}

} // namespace
Expand Down Expand Up @@ -54,4 +55,14 @@ int32_t PlatformVerification::ChallengePlatform(
callback.pp_completion_callback());
}

int32_t PlatformVerification::GetStorageId(Var* storage_id,
const CompletionCallback& callback) {
if (!HasInterface())
return callback.MayForce(PP_ERROR_NOINTERFACE);

return GetInterface()->GetStorageId(
pp_resource(), const_cast<PP_Var*>(&storage_id->pp_var()),
callback.pp_completion_callback());
}

} // namespace pp
1 change: 1 addition & 0 deletions ppapi/cpp/private/platform_verification.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class PlatformVerification : public Resource {
Var* signed_data_signature,
Var* platform_key_certificate,
const CompletionCallback& callback);
int32_t GetStorageId(Var* storage_id, const CompletionCallback& callback);
};

} // namespace pp
Expand Down
40 changes: 23 additions & 17 deletions ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetAddress_Private_0_1;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetAddress_Private_1_0;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetAddress_Private_1_1;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_OutputProtection_Private_0_1;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_PlatformVerification_Private_0_2;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_PlatformVerification_Private_0_3;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TCPServerSocket_Private_0_1;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TCPServerSocket_Private_0_2;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TCPSocket_Private_0_3;
Expand Down Expand Up @@ -4113,24 +4113,29 @@ static int32_t Pnacl_M31_PPB_OutputProtection_Private_EnableProtection(PP_Resour

/* End wrapper methods for PPB_OutputProtection_Private_0_1 */

/* Begin wrapper methods for PPB_PlatformVerification_Private_0_2 */
/* Begin wrapper methods for PPB_PlatformVerification_Private_0_3 */

static PP_Resource Pnacl_M32_PPB_PlatformVerification_Private_Create(PP_Instance instance) {
const struct PPB_PlatformVerification_Private_0_2 *iface = Pnacl_WrapperInfo_PPB_PlatformVerification_Private_0_2.real_iface;
static PP_Resource Pnacl_M61_PPB_PlatformVerification_Private_Create(PP_Instance instance) {
const struct PPB_PlatformVerification_Private_0_3 *iface = Pnacl_WrapperInfo_PPB_PlatformVerification_Private_0_3.real_iface;
return iface->Create(instance);
}

static PP_Bool Pnacl_M32_PPB_PlatformVerification_Private_IsPlatformVerification(PP_Resource resource) {
const struct PPB_PlatformVerification_Private_0_2 *iface = Pnacl_WrapperInfo_PPB_PlatformVerification_Private_0_2.real_iface;
static PP_Bool Pnacl_M61_PPB_PlatformVerification_Private_IsPlatformVerification(PP_Resource resource) {
const struct PPB_PlatformVerification_Private_0_3 *iface = Pnacl_WrapperInfo_PPB_PlatformVerification_Private_0_3.real_iface;
return iface->IsPlatformVerification(resource);
}

static int32_t Pnacl_M32_PPB_PlatformVerification_Private_ChallengePlatform(PP_Resource instance, struct PP_Var* service_id, struct PP_Var* challenge, struct PP_Var* signed_data, struct PP_Var* signed_data_signature, struct PP_Var* platform_key_certificate, struct PP_CompletionCallback* callback) {
const struct PPB_PlatformVerification_Private_0_2 *iface = Pnacl_WrapperInfo_PPB_PlatformVerification_Private_0_2.real_iface;
static int32_t Pnacl_M61_PPB_PlatformVerification_Private_ChallengePlatform(PP_Resource instance, struct PP_Var* service_id, struct PP_Var* challenge, struct PP_Var* signed_data, struct PP_Var* signed_data_signature, struct PP_Var* platform_key_certificate, struct PP_CompletionCallback* callback) {
const struct PPB_PlatformVerification_Private_0_3 *iface = Pnacl_WrapperInfo_PPB_PlatformVerification_Private_0_3.real_iface;
return iface->ChallengePlatform(instance, *service_id, *challenge, signed_data, signed_data_signature, platform_key_certificate, *callback);
}

/* End wrapper methods for PPB_PlatformVerification_Private_0_2 */
static int32_t Pnacl_M61_PPB_PlatformVerification_Private_GetStorageId(PP_Resource instance, struct PP_Var* storage_id, struct PP_CompletionCallback* callback) {
const struct PPB_PlatformVerification_Private_0_3 *iface = Pnacl_WrapperInfo_PPB_PlatformVerification_Private_0_3.real_iface;
return iface->GetStorageId(instance, storage_id, *callback);
}

/* End wrapper methods for PPB_PlatformVerification_Private_0_3 */

/* Begin wrapper methods for PPB_TCPServerSocket_Private_0_1 */

Expand Down Expand Up @@ -5894,10 +5899,11 @@ static const struct PPB_OutputProtection_Private_0_1 Pnacl_Wrappers_PPB_OutputPr
.EnableProtection = (int32_t (*)(PP_Resource resource, uint32_t desired_protection_mask, struct PP_CompletionCallback callback))&Pnacl_M31_PPB_OutputProtection_Private_EnableProtection
};

static const struct PPB_PlatformVerification_Private_0_2 Pnacl_Wrappers_PPB_PlatformVerification_Private_0_2 = {
.Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M32_PPB_PlatformVerification_Private_Create,
.IsPlatformVerification = (PP_Bool (*)(PP_Resource resource))&Pnacl_M32_PPB_PlatformVerification_Private_IsPlatformVerification,
.ChallengePlatform = (int32_t (*)(PP_Resource instance, struct PP_Var service_id, struct PP_Var challenge, struct PP_Var* signed_data, struct PP_Var* signed_data_signature, struct PP_Var* platform_key_certificate, struct PP_CompletionCallback callback))&Pnacl_M32_PPB_PlatformVerification_Private_ChallengePlatform
static const struct PPB_PlatformVerification_Private_0_3 Pnacl_Wrappers_PPB_PlatformVerification_Private_0_3 = {
.Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M61_PPB_PlatformVerification_Private_Create,
.IsPlatformVerification = (PP_Bool (*)(PP_Resource resource))&Pnacl_M61_PPB_PlatformVerification_Private_IsPlatformVerification,
.ChallengePlatform = (int32_t (*)(PP_Resource instance, struct PP_Var service_id, struct PP_Var challenge, struct PP_Var* signed_data, struct PP_Var* signed_data_signature, struct PP_Var* platform_key_certificate, struct PP_CompletionCallback callback))&Pnacl_M61_PPB_PlatformVerification_Private_ChallengePlatform,
.GetStorageId = (int32_t (*)(PP_Resource instance, struct PP_Var* storage_id, struct PP_CompletionCallback callback))&Pnacl_M61_PPB_PlatformVerification_Private_GetStorageId
};

static const struct PPB_TCPServerSocket_Private_0_1 Pnacl_Wrappers_PPB_TCPServerSocket_Private_0_1 = {
Expand Down Expand Up @@ -6663,9 +6669,9 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_OutputProtection_Private_
.real_iface = NULL
};

static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_PlatformVerification_Private_0_2 = {
.iface_macro = PPB_PLATFORMVERIFICATION_PRIVATE_INTERFACE_0_2,
.wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_PlatformVerification_Private_0_2,
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_PlatformVerification_Private_0_3 = {
.iface_macro = PPB_PLATFORMVERIFICATION_PRIVATE_INTERFACE_0_3,
.wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_PlatformVerification_Private_0_3,
.real_iface = NULL
};

Expand Down Expand Up @@ -6858,7 +6864,7 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = {
&Pnacl_WrapperInfo_PPB_NetAddress_Private_1_0,
&Pnacl_WrapperInfo_PPB_NetAddress_Private_1_1,
&Pnacl_WrapperInfo_PPB_OutputProtection_Private_0_1,
&Pnacl_WrapperInfo_PPB_PlatformVerification_Private_0_2,
&Pnacl_WrapperInfo_PPB_PlatformVerification_Private_0_3,
&Pnacl_WrapperInfo_PPB_TCPServerSocket_Private_0_1,
&Pnacl_WrapperInfo_PPB_TCPServerSocket_Private_0_2,
&Pnacl_WrapperInfo_PPB_TCPSocket_Private_0_3,
Expand Down
33 changes: 33 additions & 0 deletions ppapi/proxy/platform_verification_private_resource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,38 @@ void PlatformVerificationPrivateResource::OnChallengePlatformReply(
output_params.callback->Run(params.result());
}

int32_t PlatformVerificationPrivateResource::GetStorageId(
PP_Var* storage_id,
const scoped_refptr<TrackedCallback>& callback) {
// Prevent null types for obvious reasons, but also ref-counted types to
// avoid leaks on failures (since they're only written to on success).
if (!storage_id || VarTracker::IsVarTypeRefcounted(storage_id->type)) {
return PP_ERROR_BADARGUMENT;
}

GetStorageIdParams output_params = {storage_id, callback};

Call<PpapiHostMsg_PlatformVerification_GetStorageIdReply>(
BROWSER, PpapiHostMsg_PlatformVerification_GetStorageId(),
base::Bind(&PlatformVerificationPrivateResource::OnGetStorageIdReply,
base::Unretained(this), output_params));
return PP_OK_COMPLETIONPENDING;
}

void PlatformVerificationPrivateResource::OnGetStorageIdReply(
GetStorageIdParams output_params,
const ResourceMessageReplyParams& params,
const std::string& storage_id) {
if (!TrackedCallback::IsPending(output_params.callback) ||
TrackedCallback::IsScheduledToRun(output_params.callback)) {
return;
}

if (params.result() == PP_OK) {
*(output_params.storage_id) = (new StringVar(storage_id))->GetPPVar();
}
output_params.callback->Run(params.result());
}

} // namespace proxy
} // namespace ppapi
9 changes: 9 additions & 0 deletions ppapi/proxy/platform_verification_private_resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ class PPAPI_PROXY_EXPORT PlatformVerificationPrivateResource
PP_Var* platform_key_certificate;
scoped_refptr<TrackedCallback> callback;
};
struct GetStorageIdParams {
PP_Var* storage_id;
scoped_refptr<TrackedCallback> callback;
};

~PlatformVerificationPrivateResource() override;

Expand All @@ -50,6 +54,11 @@ class PPAPI_PROXY_EXPORT PlatformVerificationPrivateResource
const std::vector<uint8_t>& raw_signed_data,
const std::vector<uint8_t>& raw_signed_data_signature,
const std::string& raw_platform_key_certificate);
int32_t GetStorageId(PP_Var* storage_id,
const scoped_refptr<TrackedCallback>& callback) override;
void OnGetStorageIdReply(GetStorageIdParams output_params,
const ResourceMessageReplyParams& params,
const std::string& storage_id);

DISALLOW_COPY_AND_ASSIGN(PlatformVerificationPrivateResource);
};
Expand Down
3 changes: 3 additions & 0 deletions ppapi/proxy/ppapi_messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -1841,6 +1841,9 @@ IPC_MESSAGE_CONTROL3(PpapiHostMsg_PlatformVerification_ChallengePlatformReply,
std::vector<uint8_t> /* signed_data */,
std::vector<uint8_t> /* signed_data_signature */,
std::string /* platform_key_certificate */)
IPC_MESSAGE_CONTROL0(PpapiHostMsg_PlatformVerification_GetStorageId)
IPC_MESSAGE_CONTROL1(PpapiHostMsg_PlatformVerification_GetStorageIdReply,
std::string /* storage_id */)

// Printing.
IPC_MESSAGE_CONTROL0(PpapiHostMsg_Printing_Create)
Expand Down
12 changes: 12 additions & 0 deletions ppapi/tests/test_platform_verification_private.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ TestPlatformVerificationPrivate::TestPlatformVerificationPrivate(

void TestPlatformVerificationPrivate::RunTests(const std::string& filter) {
RUN_CALLBACK_TEST(TestPlatformVerificationPrivate, ChallengePlatform, filter);
RUN_CALLBACK_TEST(TestPlatformVerificationPrivate, StorageId, filter);
}

std::string TestPlatformVerificationPrivate::TestChallengePlatform() {
Expand All @@ -43,3 +44,14 @@ std::string TestPlatformVerificationPrivate::TestChallengePlatform() {
ASSERT_EQ(PP_ERROR_FAILED, callback.result());
PASS();
}

std::string TestPlatformVerificationPrivate::TestStorageId() {
pp::PlatformVerification platform_verification_api(instance_);
TestCompletionCallback callback(instance_->pp_instance(), callback_type());
pp::Var storage_id;
callback.WaitForResult(platform_verification_api.GetStorageId(
&storage_id, callback.GetCallback()));
CHECK_CALLBACK_BEHAVIOR(callback);
ASSERT_EQ(PP_OK, callback.result());
PASS();
}
1 change: 1 addition & 0 deletions ppapi/tests/test_platform_verification_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class TestPlatformVerificationPrivate : public TestCase {

private:
std::string TestChallengePlatform();
std::string TestStorageId();
};

#endif // PAPPI_TESTS_TEST_PLATFORM_VERIFICATION_PRIVATE_H_
Loading

0 comments on commit dc89b14

Please sign in to comment.