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

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

Issue 925783002: Split ValueSerializer into separate Serializer and Deserializer classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed cpplint warnings. Created 5 years, 9 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
« no previous file with comments | « chromeos/app_mode/kiosk_oem_manifest_parser.cc ('k') | chromeos/network/onc/onc_test_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 // Keys generated using |GenerateEcP256KeyPair| are in the following format: 11 // Keys generated using |GenerateEcP256KeyPair| are in the following format:
12 // "{<key_type>: <key_pair_index>}". 12 // "{<key_type>: <key_pair_index>}".
13 // <key_pair_index> is an integer identifying 13 // <key_pair_index> is an integer identifying
14 // the key pair. 14 // the key pair.
15 // <key_type> specifies whether the key is public or private. It can have one 15 // <key_type> specifies whether the key is public or private. It can have one
16 // of the following valies: 16 // of the following valies:
17 const char kEc256PrivateKeyKey[] = "ec_p256_private_key"; 17 const char kEc256PrivateKeyKey[] = "ec_p256_private_key";
18 const char kEc256PublicKeyKey[] = "ec_p256_public_key"; 18 const char kEc256PublicKeyKey[] = "ec_p256_public_key";
19 19
20 // Extracts key pair index from a key in format "<key_type>: <key_pair_index>}". 20 // Extracts key pair index from a key in format "<key_type>: <key_pair_index>}".
21 int ExtractKeyPairIndexFromKey(const std::string& key, 21 int ExtractKeyPairIndexFromKey(const std::string& key,
22 const std::string& key_type) { 22 const std::string& key_type) {
23 JSONStringValueSerializer serializer(key); 23 JSONStringValueDeserializer deserializer(key);
24 scoped_ptr<base::Value> json_value(serializer.Deserialize(NULL, NULL)); 24 scoped_ptr<base::Value> json_value(deserializer.Deserialize(NULL, NULL));
25 if (!json_value) 25 if (!json_value)
26 return -1; 26 return -1;
27 27
28 base::DictionaryValue* json_dictionary = NULL; 28 base::DictionaryValue* json_dictionary = NULL;
29 if (!json_value->GetAsDictionary(&json_dictionary)) 29 if (!json_value->GetAsDictionary(&json_dictionary))
30 return -1; 30 return -1;
31 31
32 int key_pair_index = -1; 32 int key_pair_index = -1;
33 if (!json_dictionary->GetInteger(key_type, &key_pair_index)) 33 if (!json_dictionary->GetInteger(key_type, &key_pair_index))
34 return -1; 34 return -1;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 "\"signature_type\": \"%s\"" 143 "\"signature_type\": \"%s\""
144 "}}", 144 "}}",
145 message.c_str(), 145 message.c_str(),
146 options.key.c_str(), 146 options.key.c_str(),
147 options.associated_data.c_str(), 147 options.associated_data.c_str(),
148 options.encryption_type.c_str(), 148 options.encryption_type.c_str(),
149 options.signature_type.c_str())); 149 options.signature_type.c_str()));
150 } 150 }
151 151
152 } // namespace chromeos 152 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/app_mode/kiosk_oem_manifest_parser.cc ('k') | chromeos/network/onc/onc_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698