Skip to content

Commit

Permalink
Add device management (DM) request/response parser.
Browse files Browse the repository at this point in the history
This is part of the changes for enterprise support in 
Chromium updater. The added code is to construct the 
request send to DM server and parse the response into 
an internal data structure.

This feature is a rewrite of a similar feature already
present in Omaha (Google Update).

This CL also introduces the dependency on //crypto. This is to enable
the parser to verify the SHA256 signature in the response and to
extract the public key for future response verification. In the unit
test, crypto lib is also used for signature creation. 

Bug: 1068797
Change-Id: Ieaa3565ff7293cfb52858ae39d18a794ef7a8823
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2276535
Commit-Queue: Xiaoling Bao <xiaolingbao@chromium.org>
Reviewed-by: Adam Langley <agl@chromium.org>
Reviewed-by: Sorin Jianu <sorin@chromium.org>
Reviewed-by: S. Ganesh <ganesh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#785582}
  • Loading branch information
xiaolingbao authored and Commit Bot committed Jul 7, 2020
1 parent b968841 commit 43989c7
Show file tree
Hide file tree
Showing 10 changed files with 1,136 additions and 15 deletions.
13 changes: 12 additions & 1 deletion chrome/updater/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ if (is_win || is_mac) {
"configurator.h",
"dm_cached_policy_info.cc",
"dm_cached_policy_info.h",
"dm_message.cc",
"dm_message.h",
"dm_policy_manager.cc",
"dm_policy_manager.h",
"dm_storage.cc",
Expand Down Expand Up @@ -163,9 +165,14 @@ if (is_win || is_mac) {
"//components/prefs",
"//components/update_client",
"//components/version_info",
"//crypto",
"//third_party/boringssl",
"//url",
]
public_deps = [ "//components/policy/proto" ]
public_deps = [
"//components/policy/core/common:common",
"//components/policy/proto",
]

if (is_win) {
deps += [
Expand Down Expand Up @@ -224,6 +231,9 @@ if (is_win || is_mac) {

sources = [
"app/app_server_unittest.cc",
"dm_message_unittest.cc",
"dm_policy_builder_for_testing.cc",
"dm_policy_builder_for_testing.h",
"dm_policy_manager_unittest.cc",
"dm_storage_unittest.cc",
"external_constants_unittest.cc",
Expand Down Expand Up @@ -254,6 +264,7 @@ if (is_win || is_mac) {
"//chrome/updater/tools:unittest",
"//components/prefs:test_support",
"//components/update_client",
"//crypto",
"//testing/gtest",
"//url",
]
Expand Down
3 changes: 2 additions & 1 deletion chrome/updater/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ include_rules = [
"+components/update_client",
"+components/version_info",
"+courgette",
"+crypto",
"+third_party/boringssl",
"+third_party/crashpad",
"+third_party/zlib/google",
"+third_party/boringssl/src/include",
]
11 changes: 5 additions & 6 deletions chrome/updater/dm_cached_policy_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,29 @@
#ifndef CHROME_UPDATER_DM_CACHED_POLICY_INFO_H_
#define CHROME_UPDATER_DM_CACHED_POLICY_INFO_H_

#include <stdint.h>
#include <string>

namespace updater {

class CachedPolicyInfo {
public:
CachedPolicyInfo();
CachedPolicyInfo(const CachedPolicyInfo&) = delete;
CachedPolicyInfo& operator=(const CachedPolicyInfo& other) = delete;
~CachedPolicyInfo();

// Populate members with serialized data of DM PolicyFetchResponse.
bool Populate(const std::string& raw_response);

// Public key of the policy.
std::string PublicKey() const { return key_; }
std::string public_key() const { return key_; }

// Version of the public key. -1 means the key is not versioned or unknown.
int32_t KeyVersion() const { return key_version_; }
int32_t key_version() const { return key_version_; }

bool HasKeyVersion() const { return key_version_ >= 0; }
bool has_key_version() const { return key_version_ >= 0; }

// Signing timestamp.
int64_t TimeStamp() const { return timestamp_; }
int64_t timestamp() const { return timestamp_; }

private:
std::string key_;
Expand Down

0 comments on commit 43989c7

Please sign in to comment.