1 //
2 // Copyright (C) 2015 The Android Open Source Project
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 // THIS CODE IS GENERATED.
17
18 #include "tpm_manager/common/print_local_data_proto.h"
19
20 #include <string>
21
22 #include <base/strings/string_number_conversions.h>
23 #include <base/strings/stringprintf.h>
24
25 namespace tpm_manager {
26
GetProtoDebugString(const LocalData & value)27 std::string GetProtoDebugString(const LocalData& value) {
28 return GetProtoDebugStringWithIndent(value, 0);
29 }
30
GetProtoDebugStringWithIndent(const LocalData & value,int indent_size)31 std::string GetProtoDebugStringWithIndent(const LocalData& value,
32 int indent_size) {
33 std::string indent(indent_size, ' ');
34 std::string output =
35 base::StringPrintf("[%s] {\n", value.GetTypeName().c_str());
36
37 if (value.has_owner_password()) {
38 output += indent + " owner_password: ";
39 base::StringAppendF(&output, "%s",
40 base::HexEncode(value.owner_password().data(),
41 value.owner_password().size())
42 .c_str());
43 output += "\n";
44 }
45 output += indent + " owner_dependency: {";
46 for (int i = 0; i < value.owner_dependency_size(); ++i) {
47 base::StringAppendF(&output, "%s", value.owner_dependency(i).c_str());
48 }
49 output += "}\n";
50 if (value.has_endorsement_password()) {
51 output += indent + " endorsement_password: ";
52 base::StringAppendF(&output, "%s",
53 base::HexEncode(value.endorsement_password().data(),
54 value.endorsement_password().size())
55 .c_str());
56 output += "\n";
57 }
58 if (value.has_lockout_password()) {
59 output += indent + " lockout_password: ";
60 base::StringAppendF(&output, "%s",
61 base::HexEncode(value.lockout_password().data(),
62 value.lockout_password().size())
63 .c_str());
64 output += "\n";
65 }
66 output += indent + "}\n";
67 return output;
68 }
69
70 } // namespace tpm_manager
71