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

Side by Side Diff: chromeos/dbus/fake_easy_unlock_client.cc

Issue 569813002: Minor cleanup in EasyUnlockClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "base/json/json_string_value_serializer.h" 5 #include "base/json/json_string_value_serializer.h"
6 #include "base/strings/stringprintf.h" 6 #include "base/strings/stringprintf.h"
7 #include "chromeos/dbus/fake_easy_unlock_client.h" 7 #include "chromeos/dbus/fake_easy_unlock_client.h"
8 8
9 namespace { 9 namespace {
10 10
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 // same shared key. To achieve this, identify the created key by sum and 88 // same shared key. To achieve this, identify the created key by sum and
89 // product of the used key pairs. 89 // product of the used key pairs.
90 callback.Run(base::StringPrintf( 90 callback.Run(base::StringPrintf(
91 "{\"secret_key\": [%d, %d]}", 91 "{\"secret_key\": [%d, %d]}",
92 private_key_index + public_key_index, 92 private_key_index + public_key_index,
93 private_key_index * public_key_index)); 93 private_key_index * public_key_index));
94 } 94 }
95 95
96 void FakeEasyUnlockClient::CreateSecureMessage( 96 void FakeEasyUnlockClient::CreateSecureMessage(
97 const std::string& payload, 97 const std::string& payload,
98 const std::string& key, 98 const CreateSecureMessageOptions& options,
99 const std::string& associated_data,
100 const std::string& public_metadata,
101 const std::string& verification_key_id,
102 const std::string& decryption_key_id,
103 const std::string& encryption_type,
104 const std::string& signature_type,
105 const DataCallback& callback) { 99 const DataCallback& callback) {
106 callback.Run(base::StringPrintf( 100 callback.Run(base::StringPrintf(
107 "{\"securemessage\": {" 101 "{\"securemessage\": {"
108 "\"payload\": \"%s\"," 102 "\"payload\": \"%s\","
109 "\"key\": \"%s\"," 103 "\"key\": \"%s\","
110 "\"associated_data\": \"%s\"," 104 "\"associated_data\": \"%s\","
111 "\"public_metadata\": \"%s\"," 105 "\"public_metadata\": \"%s\","
112 "\"verification_key_id\": \"%s\"," 106 "\"verification_key_id\": \"%s\","
113 "\"decryption_key_id\": \"%s\"," 107 "\"decryption_key_id\": \"%s\","
114 "\"encryption_type\": \"%s\"," 108 "\"encryption_type\": \"%s\","
115 "\"signature_type\": \"%s\"" 109 "\"signature_type\": \"%s\""
116 "}}", 110 "}}",
117 payload.c_str(), 111 payload.c_str(),
118 key.c_str(), 112 options.key.c_str(),
119 associated_data.c_str(), 113 options.associated_data.c_str(),
120 public_metadata.c_str(), 114 options.public_metadata.c_str(),
121 verification_key_id.c_str(), 115 options.verification_key_id.c_str(),
122 decryption_key_id.c_str(), 116 options.decryption_key_id.c_str(),
123 encryption_type.c_str(), 117 options.encryption_type.c_str(),
124 signature_type.c_str())); 118 options.signature_type.c_str()));
125 } 119 }
126 120
127 void FakeEasyUnlockClient::UnwrapSecureMessage( 121 void FakeEasyUnlockClient::UnwrapSecureMessage(
128 const std::string& message, 122 const std::string& message,
129 const std::string& key, 123 const UnwrapSecureMessageOptions& options,
130 const std::string& associated_data,
131 const std::string& encryption_type,
132 const std::string& signature_type,
133 const DataCallback& callback) { 124 const DataCallback& callback) {
134 // TODO(tbarzic): Verify that |message| is in the format returned by 125 // TODO(tbarzic): Verify that |message| is in the format returned by
135 // |CreateSecureMessage| and extract payload, metadata and 126 // |CreateSecureMessage| and extract payload, metadata and
136 // verification_key_id from there. 127 // verification_key_id from there.
137 callback.Run(base::StringPrintf( 128 callback.Run(base::StringPrintf(
138 "{\"unwrapped_securemessage\": {" 129 "{\"unwrapped_securemessage\": {"
139 "\"message\": \"%s\"," 130 "\"message\": \"%s\","
140 "\"key\": \"%s\"," 131 "\"key\": \"%s\","
141 "\"associated_data\": \"%s\"," 132 "\"associated_data\": \"%s\","
142 "\"encryption_type\": \"%s\"," 133 "\"encryption_type\": \"%s\","
143 "\"signature_type\": \"%s\"" 134 "\"signature_type\": \"%s\""
144 "}}", 135 "}}",
145 message.c_str(), 136 message.c_str(),
146 key.c_str(), 137 options.key.c_str(),
147 associated_data.c_str(), 138 options.associated_data.c_str(),
148 encryption_type.c_str(), 139 options.encryption_type.c_str(),
149 signature_type.c_str())); 140 options.signature_type.c_str()));
150 } 141 }
151 142
152 } // namespace chromeos 143 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/fake_easy_unlock_client.h ('k') | chromeos/dbus/fake_easy_unlock_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698