1 // Copyright 2016 The Chromium OS Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // THIS CODE IS GENERATED. 6 7 #include "tpm_manager/common/print_tpm_manager_proto.h" 8 9 #include <string> 10 11 #include <base/strings/string_number_conversions.h> 12 #include <base/strings/stringprintf.h> 13 14 namespace tpm_manager { 15 16 std::string GetProtoDebugString(TpmManagerStatus value) { 17 return GetProtoDebugStringWithIndent(value, 0); 18 } 19 20 std::string GetProtoDebugStringWithIndent(TpmManagerStatus value, 21 int indent_size) { 22 if (value == STATUS_SUCCESS) { 23 return "STATUS_SUCCESS"; 24 } 25 if (value == STATUS_DEVICE_ERROR) { 26 return "STATUS_DEVICE_ERROR"; 27 } 28 if (value == STATUS_NOT_AVAILABLE) { 29 return "STATUS_NOT_AVAILABLE"; 30 } 31 return "<unknown>"; 32 } 33 34 std::string GetProtoDebugString(NvramResult value) { 35 return GetProtoDebugStringWithIndent(value, 0); 36 } 37 38 std::string GetProtoDebugStringWithIndent(NvramResult value, int indent_size) { 39 if (value == NVRAM_RESULT_SUCCESS) { 40 return "NVRAM_RESULT_SUCCESS"; 41 } 42 if (value == NVRAM_RESULT_DEVICE_ERROR) { 43 return "NVRAM_RESULT_DEVICE_ERROR"; 44 } 45 if (value == NVRAM_RESULT_ACCESS_DENIED) { 46 return "NVRAM_RESULT_ACCESS_DENIED"; 47 } 48 if (value == NVRAM_RESULT_INVALID_PARAMETER) { 49 return "NVRAM_RESULT_INVALID_PARAMETER"; 50 } 51 if (value == NVRAM_RESULT_SPACE_DOES_NOT_EXIST) { 52 return "NVRAM_RESULT_SPACE_DOES_NOT_EXIST"; 53 } 54 if (value == NVRAM_RESULT_SPACE_ALREADY_EXISTS) { 55 return "NVRAM_RESULT_SPACE_ALREADY_EXISTS"; 56 } 57 if (value == NVRAM_RESULT_OPERATION_DISABLED) { 58 return "NVRAM_RESULT_OPERATION_DISABLED"; 59 } 60 if (value == NVRAM_RESULT_INSUFFICIENT_SPACE) { 61 return "NVRAM_RESULT_INSUFFICIENT_SPACE"; 62 } 63 if (value == NVRAM_RESULT_IPC_ERROR) { 64 return "NVRAM_RESULT_IPC_ERROR"; 65 } 66 return "<unknown>"; 67 } 68 69 std::string GetProtoDebugString(NvramSpaceAttribute value) { 70 return GetProtoDebugStringWithIndent(value, 0); 71 } 72 73 std::string GetProtoDebugStringWithIndent(NvramSpaceAttribute value, 74 int indent_size) { 75 if (value == NVRAM_PERSISTENT_WRITE_LOCK) { 76 return "NVRAM_PERSISTENT_WRITE_LOCK"; 77 } 78 if (value == NVRAM_BOOT_WRITE_LOCK) { 79 return "NVRAM_BOOT_WRITE_LOCK"; 80 } 81 if (value == NVRAM_BOOT_READ_LOCK) { 82 return "NVRAM_BOOT_READ_LOCK"; 83 } 84 if (value == NVRAM_WRITE_AUTHORIZATION) { 85 return "NVRAM_WRITE_AUTHORIZATION"; 86 } 87 if (value == NVRAM_READ_AUTHORIZATION) { 88 return "NVRAM_READ_AUTHORIZATION"; 89 } 90 if (value == NVRAM_WRITE_EXTEND) { 91 return "NVRAM_WRITE_EXTEND"; 92 } 93 if (value == NVRAM_GLOBAL_LOCK) { 94 return "NVRAM_GLOBAL_LOCK"; 95 } 96 if (value == NVRAM_PLATFORM_WRITE) { 97 return "NVRAM_PLATFORM_WRITE"; 98 } 99 if (value == NVRAM_OWNER_WRITE) { 100 return "NVRAM_OWNER_WRITE"; 101 } 102 if (value == NVRAM_OWNER_READ) { 103 return "NVRAM_OWNER_READ"; 104 } 105 return "<unknown>"; 106 } 107 108 std::string GetProtoDebugString(NvramSpacePolicy value) { 109 return GetProtoDebugStringWithIndent(value, 0); 110 } 111 112 std::string GetProtoDebugStringWithIndent(NvramSpacePolicy value, 113 int indent_size) { 114 if (value == NVRAM_POLICY_NONE) { 115 return "NVRAM_POLICY_NONE"; 116 } 117 if (value == NVRAM_POLICY_PCR0) { 118 return "NVRAM_POLICY_PCR0"; 119 } 120 return "<unknown>"; 121 } 122 123 std::string GetProtoDebugString(const NvramPolicyRecord& value) { 124 return GetProtoDebugStringWithIndent(value, 0); 125 } 126 127 std::string GetProtoDebugStringWithIndent(const NvramPolicyRecord& value, 128 int indent_size) { 129 std::string indent(indent_size, ' '); 130 std::string output = 131 base::StringPrintf("[%s] {\n", value.GetTypeName().c_str()); 132 133 if (value.has_index()) { 134 output += indent + " index: "; 135 base::StringAppendF(&output, "%u (0x%08X)", value.index(), value.index()); 136 output += "\n"; 137 } 138 if (value.has_policy()) { 139 output += indent + " policy: "; 140 base::StringAppendF( 141 &output, "%s", 142 GetProtoDebugStringWithIndent(value.policy(), indent_size + 2).c_str()); 143 output += "\n"; 144 } 145 if (value.has_world_read_allowed()) { 146 output += indent + " world_read_allowed: "; 147 base::StringAppendF(&output, "%s", 148 value.world_read_allowed() ? "true" : "false"); 149 output += "\n"; 150 } 151 if (value.has_world_write_allowed()) { 152 output += indent + " world_write_allowed: "; 153 base::StringAppendF(&output, "%s", 154 value.world_write_allowed() ? "true" : "false"); 155 output += "\n"; 156 } 157 output += indent + " policy_digests: {"; 158 for (int i = 0; i < value.policy_digests_size(); ++i) { 159 if (i > 0) { 160 base::StringAppendF(&output, ", "); 161 } 162 base::StringAppendF(&output, "%s", 163 base::HexEncode(value.policy_digests(i).data(), 164 value.policy_digests(i).size()) 165 .c_str()); 166 } 167 output += "}\n"; 168 output += indent + "}\n"; 169 return output; 170 } 171 172 std::string GetProtoDebugString(const LocalData& value) { 173 return GetProtoDebugStringWithIndent(value, 0); 174 } 175 176 std::string GetProtoDebugStringWithIndent(const LocalData& value, 177 int indent_size) { 178 std::string indent(indent_size, ' '); 179 std::string output = 180 base::StringPrintf("[%s] {\n", value.GetTypeName().c_str()); 181 182 if (value.has_owner_password()) { 183 output += indent + " owner_password: "; 184 base::StringAppendF(&output, "%s", 185 base::HexEncode(value.owner_password().data(), 186 value.owner_password().size()) 187 .c_str()); 188 output += "\n"; 189 } 190 output += indent + " owner_dependency: {"; 191 for (int i = 0; i < value.owner_dependency_size(); ++i) { 192 if (i > 0) { 193 base::StringAppendF(&output, ", "); 194 } 195 base::StringAppendF(&output, "%s", value.owner_dependency(i).c_str()); 196 } 197 output += "}\n"; 198 if (value.has_endorsement_password()) { 199 output += indent + " endorsement_password: "; 200 base::StringAppendF(&output, "%s", 201 base::HexEncode(value.endorsement_password().data(), 202 value.endorsement_password().size()) 203 .c_str()); 204 output += "\n"; 205 } 206 if (value.has_lockout_password()) { 207 output += indent + " lockout_password: "; 208 base::StringAppendF(&output, "%s", 209 base::HexEncode(value.lockout_password().data(), 210 value.lockout_password().size()) 211 .c_str()); 212 output += "\n"; 213 } 214 output += indent + " nvram_policy: {"; 215 for (int i = 0; i < value.nvram_policy_size(); ++i) { 216 if (i > 0) { 217 base::StringAppendF(&output, ", "); 218 } 219 base::StringAppendF( 220 &output, "%s", 221 GetProtoDebugStringWithIndent(value.nvram_policy(i), indent_size + 2) 222 .c_str()); 223 } 224 output += "}\n"; 225 output += indent + "}\n"; 226 return output; 227 } 228 229 std::string GetProtoDebugString(const DefineSpaceRequest& value) { 230 return GetProtoDebugStringWithIndent(value, 0); 231 } 232 233 std::string GetProtoDebugStringWithIndent(const DefineSpaceRequest& value, 234 int indent_size) { 235 std::string indent(indent_size, ' '); 236 std::string output = 237 base::StringPrintf("[%s] {\n", value.GetTypeName().c_str()); 238 239 if (value.has_index()) { 240 output += indent + " index: "; 241 base::StringAppendF(&output, "%u (0x%08X)", value.index(), value.index()); 242 output += "\n"; 243 } 244 if (value.has_size()) { 245 output += indent + " size: "; 246 base::StringAppendF(&output, "%u (0x%08X)", value.size(), value.size()); 247 output += "\n"; 248 } 249 output += indent + " attributes: {"; 250 for (int i = 0; i < value.attributes_size(); ++i) { 251 if (i > 0) { 252 base::StringAppendF(&output, ", "); 253 } 254 base::StringAppendF(&output, "%s", GetProtoDebugStringWithIndent( 255 value.attributes(i), indent_size + 2) 256 .c_str()); 257 } 258 output += "}\n"; 259 if (value.has_authorization_value()) { 260 output += indent + " authorization_value: "; 261 base::StringAppendF(&output, "%s", 262 base::HexEncode(value.authorization_value().data(), 263 value.authorization_value().size()) 264 .c_str()); 265 output += "\n"; 266 } 267 if (value.has_policy()) { 268 output += indent + " policy: "; 269 base::StringAppendF( 270 &output, "%s", 271 GetProtoDebugStringWithIndent(value.policy(), indent_size + 2).c_str()); 272 output += "\n"; 273 } 274 output += indent + "}\n"; 275 return output; 276 } 277 278 std::string GetProtoDebugString(const DefineSpaceReply& value) { 279 return GetProtoDebugStringWithIndent(value, 0); 280 } 281 282 std::string GetProtoDebugStringWithIndent(const DefineSpaceReply& value, 283 int indent_size) { 284 std::string indent(indent_size, ' '); 285 std::string output = 286 base::StringPrintf("[%s] {\n", value.GetTypeName().c_str()); 287 288 if (value.has_result()) { 289 output += indent + " result: "; 290 base::StringAppendF( 291 &output, "%s", 292 GetProtoDebugStringWithIndent(value.result(), indent_size + 2).c_str()); 293 output += "\n"; 294 } 295 output += indent + "}\n"; 296 return output; 297 } 298 299 std::string GetProtoDebugString(const DestroySpaceRequest& value) { 300 return GetProtoDebugStringWithIndent(value, 0); 301 } 302 303 std::string GetProtoDebugStringWithIndent(const DestroySpaceRequest& value, 304 int indent_size) { 305 std::string indent(indent_size, ' '); 306 std::string output = 307 base::StringPrintf("[%s] {\n", value.GetTypeName().c_str()); 308 309 if (value.has_index()) { 310 output += indent + " index: "; 311 base::StringAppendF(&output, "%u (0x%08X)", value.index(), value.index()); 312 output += "\n"; 313 } 314 output += indent + "}\n"; 315 return output; 316 } 317 318 std::string GetProtoDebugString(const DestroySpaceReply& value) { 319 return GetProtoDebugStringWithIndent(value, 0); 320 } 321 322 std::string GetProtoDebugStringWithIndent(const DestroySpaceReply& value, 323 int indent_size) { 324 std::string indent(indent_size, ' '); 325 std::string output = 326 base::StringPrintf("[%s] {\n", value.GetTypeName().c_str()); 327 328 if (value.has_result()) { 329 output += indent + " result: "; 330 base::StringAppendF( 331 &output, "%s", 332 GetProtoDebugStringWithIndent(value.result(), indent_size + 2).c_str()); 333 output += "\n"; 334 } 335 output += indent + "}\n"; 336 return output; 337 } 338 339 std::string GetProtoDebugString(const WriteSpaceRequest& value) { 340 return GetProtoDebugStringWithIndent(value, 0); 341 } 342 343 std::string GetProtoDebugStringWithIndent(const WriteSpaceRequest& value, 344 int indent_size) { 345 std::string indent(indent_size, ' '); 346 std::string output = 347 base::StringPrintf("[%s] {\n", value.GetTypeName().c_str()); 348 349 if (value.has_index()) { 350 output += indent + " index: "; 351 base::StringAppendF(&output, "%u (0x%08X)", value.index(), value.index()); 352 output += "\n"; 353 } 354 if (value.has_data()) { 355 output += indent + " data: "; 356 base::StringAppendF( 357 &output, "%s", 358 base::HexEncode(value.data().data(), value.data().size()).c_str()); 359 output += "\n"; 360 } 361 if (value.has_authorization_value()) { 362 output += indent + " authorization_value: "; 363 base::StringAppendF(&output, "%s", 364 base::HexEncode(value.authorization_value().data(), 365 value.authorization_value().size()) 366 .c_str()); 367 output += "\n"; 368 } 369 if (value.has_use_owner_authorization()) { 370 output += indent + " use_owner_authorization: "; 371 base::StringAppendF(&output, "%s", 372 value.use_owner_authorization() ? "true" : "false"); 373 output += "\n"; 374 } 375 output += indent + "}\n"; 376 return output; 377 } 378 379 std::string GetProtoDebugString(const WriteSpaceReply& value) { 380 return GetProtoDebugStringWithIndent(value, 0); 381 } 382 383 std::string GetProtoDebugStringWithIndent(const WriteSpaceReply& value, 384 int indent_size) { 385 std::string indent(indent_size, ' '); 386 std::string output = 387 base::StringPrintf("[%s] {\n", value.GetTypeName().c_str()); 388 389 if (value.has_result()) { 390 output += indent + " result: "; 391 base::StringAppendF( 392 &output, "%s", 393 GetProtoDebugStringWithIndent(value.result(), indent_size + 2).c_str()); 394 output += "\n"; 395 } 396 output += indent + "}\n"; 397 return output; 398 } 399 400 std::string GetProtoDebugString(const ReadSpaceRequest& value) { 401 return GetProtoDebugStringWithIndent(value, 0); 402 } 403 404 std::string GetProtoDebugStringWithIndent(const ReadSpaceRequest& value, 405 int indent_size) { 406 std::string indent(indent_size, ' '); 407 std::string output = 408 base::StringPrintf("[%s] {\n", value.GetTypeName().c_str()); 409 410 if (value.has_index()) { 411 output += indent + " index: "; 412 base::StringAppendF(&output, "%u (0x%08X)", value.index(), value.index()); 413 output += "\n"; 414 } 415 if (value.has_authorization_value()) { 416 output += indent + " authorization_value: "; 417 base::StringAppendF(&output, "%s", 418 base::HexEncode(value.authorization_value().data(), 419 value.authorization_value().size()) 420 .c_str()); 421 output += "\n"; 422 } 423 if (value.has_use_owner_authorization()) { 424 output += indent + " use_owner_authorization: "; 425 base::StringAppendF(&output, "%s", 426 value.use_owner_authorization() ? "true" : "false"); 427 output += "\n"; 428 } 429 output += indent + "}\n"; 430 return output; 431 } 432 433 std::string GetProtoDebugString(const ReadSpaceReply& value) { 434 return GetProtoDebugStringWithIndent(value, 0); 435 } 436 437 std::string GetProtoDebugStringWithIndent(const ReadSpaceReply& value, 438 int indent_size) { 439 std::string indent(indent_size, ' '); 440 std::string output = 441 base::StringPrintf("[%s] {\n", value.GetTypeName().c_str()); 442 443 if (value.has_result()) { 444 output += indent + " result: "; 445 base::StringAppendF( 446 &output, "%s", 447 GetProtoDebugStringWithIndent(value.result(), indent_size + 2).c_str()); 448 output += "\n"; 449 } 450 if (value.has_data()) { 451 output += indent + " data: "; 452 base::StringAppendF( 453 &output, "%s", 454 base::HexEncode(value.data().data(), value.data().size()).c_str()); 455 output += "\n"; 456 } 457 output += indent + "}\n"; 458 return output; 459 } 460 461 std::string GetProtoDebugString(const LockSpaceRequest& value) { 462 return GetProtoDebugStringWithIndent(value, 0); 463 } 464 465 std::string GetProtoDebugStringWithIndent(const LockSpaceRequest& value, 466 int indent_size) { 467 std::string indent(indent_size, ' '); 468 std::string output = 469 base::StringPrintf("[%s] {\n", value.GetTypeName().c_str()); 470 471 if (value.has_index()) { 472 output += indent + " index: "; 473 base::StringAppendF(&output, "%u (0x%08X)", value.index(), value.index()); 474 output += "\n"; 475 } 476 if (value.has_lock_read()) { 477 output += indent + " lock_read: "; 478 base::StringAppendF(&output, "%s", value.lock_read() ? "true" : "false"); 479 output += "\n"; 480 } 481 if (value.has_lock_write()) { 482 output += indent + " lock_write: "; 483 base::StringAppendF(&output, "%s", value.lock_write() ? "true" : "false"); 484 output += "\n"; 485 } 486 if (value.has_authorization_value()) { 487 output += indent + " authorization_value: "; 488 base::StringAppendF(&output, "%s", 489 base::HexEncode(value.authorization_value().data(), 490 value.authorization_value().size()) 491 .c_str()); 492 output += "\n"; 493 } 494 if (value.has_use_owner_authorization()) { 495 output += indent + " use_owner_authorization: "; 496 base::StringAppendF(&output, "%s", 497 value.use_owner_authorization() ? "true" : "false"); 498 output += "\n"; 499 } 500 output += indent + "}\n"; 501 return output; 502 } 503 504 std::string GetProtoDebugString(const LockSpaceReply& value) { 505 return GetProtoDebugStringWithIndent(value, 0); 506 } 507 508 std::string GetProtoDebugStringWithIndent(const LockSpaceReply& value, 509 int indent_size) { 510 std::string indent(indent_size, ' '); 511 std::string output = 512 base::StringPrintf("[%s] {\n", value.GetTypeName().c_str()); 513 514 if (value.has_result()) { 515 output += indent + " result: "; 516 base::StringAppendF( 517 &output, "%s", 518 GetProtoDebugStringWithIndent(value.result(), indent_size + 2).c_str()); 519 output += "\n"; 520 } 521 output += indent + "}\n"; 522 return output; 523 } 524 525 std::string GetProtoDebugString(const ListSpacesRequest& value) { 526 return GetProtoDebugStringWithIndent(value, 0); 527 } 528 529 std::string GetProtoDebugStringWithIndent(const ListSpacesRequest& value, 530 int indent_size) { 531 std::string indent(indent_size, ' '); 532 std::string output = 533 base::StringPrintf("[%s] {\n", value.GetTypeName().c_str()); 534 535 output += indent + "}\n"; 536 return output; 537 } 538 539 std::string GetProtoDebugString(const ListSpacesReply& value) { 540 return GetProtoDebugStringWithIndent(value, 0); 541 } 542 543 std::string GetProtoDebugStringWithIndent(const ListSpacesReply& value, 544 int indent_size) { 545 std::string indent(indent_size, ' '); 546 std::string output = 547 base::StringPrintf("[%s] {\n", value.GetTypeName().c_str()); 548 549 if (value.has_result()) { 550 output += indent + " result: "; 551 base::StringAppendF( 552 &output, "%s", 553 GetProtoDebugStringWithIndent(value.result(), indent_size + 2).c_str()); 554 output += "\n"; 555 } 556 output += indent + " index_list: {"; 557 for (int i = 0; i < value.index_list_size(); ++i) { 558 if (i > 0) { 559 base::StringAppendF(&output, ", "); 560 } 561 base::StringAppendF(&output, "%u (0x%08X)", value.index_list(i), 562 value.index_list(i)); 563 } 564 output += "}\n"; 565 output += indent + "}\n"; 566 return output; 567 } 568 569 std::string GetProtoDebugString(const GetSpaceInfoRequest& value) { 570 return GetProtoDebugStringWithIndent(value, 0); 571 } 572 573 std::string GetProtoDebugStringWithIndent(const GetSpaceInfoRequest& value, 574 int indent_size) { 575 std::string indent(indent_size, ' '); 576 std::string output = 577 base::StringPrintf("[%s] {\n", value.GetTypeName().c_str()); 578 579 if (value.has_index()) { 580 output += indent + " index: "; 581 base::StringAppendF(&output, "%u (0x%08X)", value.index(), value.index()); 582 output += "\n"; 583 } 584 output += indent + "}\n"; 585 return output; 586 } 587 588 std::string GetProtoDebugString(const GetSpaceInfoReply& value) { 589 return GetProtoDebugStringWithIndent(value, 0); 590 } 591 592 std::string GetProtoDebugStringWithIndent(const GetSpaceInfoReply& value, 593 int indent_size) { 594 std::string indent(indent_size, ' '); 595 std::string output = 596 base::StringPrintf("[%s] {\n", value.GetTypeName().c_str()); 597 598 if (value.has_result()) { 599 output += indent + " result: "; 600 base::StringAppendF( 601 &output, "%s", 602 GetProtoDebugStringWithIndent(value.result(), indent_size + 2).c_str()); 603 output += "\n"; 604 } 605 if (value.has_size()) { 606 output += indent + " size: "; 607 base::StringAppendF(&output, "%u (0x%08X)", value.size(), value.size()); 608 output += "\n"; 609 } 610 if (value.has_is_read_locked()) { 611 output += indent + " is_read_locked: "; 612 base::StringAppendF(&output, "%s", 613 value.is_read_locked() ? "true" : "false"); 614 output += "\n"; 615 } 616 if (value.has_is_write_locked()) { 617 output += indent + " is_write_locked: "; 618 base::StringAppendF(&output, "%s", 619 value.is_write_locked() ? "true" : "false"); 620 output += "\n"; 621 } 622 output += indent + " attributes: {"; 623 for (int i = 0; i < value.attributes_size(); ++i) { 624 if (i > 0) { 625 base::StringAppendF(&output, ", "); 626 } 627 base::StringAppendF(&output, "%s", GetProtoDebugStringWithIndent( 628 value.attributes(i), indent_size + 2) 629 .c_str()); 630 } 631 output += "}\n"; 632 if (value.has_policy()) { 633 output += indent + " policy: "; 634 base::StringAppendF( 635 &output, "%s", 636 GetProtoDebugStringWithIndent(value.policy(), indent_size + 2).c_str()); 637 output += "\n"; 638 } 639 output += indent + "}\n"; 640 return output; 641 } 642 643 std::string GetProtoDebugString(const GetTpmStatusRequest& value) { 644 return GetProtoDebugStringWithIndent(value, 0); 645 } 646 647 std::string GetProtoDebugStringWithIndent(const GetTpmStatusRequest& value, 648 int indent_size) { 649 std::string indent(indent_size, ' '); 650 std::string output = 651 base::StringPrintf("[%s] {\n", value.GetTypeName().c_str()); 652 653 output += indent + "}\n"; 654 return output; 655 } 656 657 std::string GetProtoDebugString(const GetTpmStatusReply& value) { 658 return GetProtoDebugStringWithIndent(value, 0); 659 } 660 661 std::string GetProtoDebugStringWithIndent(const GetTpmStatusReply& value, 662 int indent_size) { 663 std::string indent(indent_size, ' '); 664 std::string output = 665 base::StringPrintf("[%s] {\n", value.GetTypeName().c_str()); 666 667 if (value.has_status()) { 668 output += indent + " status: "; 669 base::StringAppendF( 670 &output, "%s", 671 GetProtoDebugStringWithIndent(value.status(), indent_size + 2).c_str()); 672 output += "\n"; 673 } 674 if (value.has_enabled()) { 675 output += indent + " enabled: "; 676 base::StringAppendF(&output, "%s", value.enabled() ? "true" : "false"); 677 output += "\n"; 678 } 679 if (value.has_owned()) { 680 output += indent + " owned: "; 681 base::StringAppendF(&output, "%s", value.owned() ? "true" : "false"); 682 output += "\n"; 683 } 684 if (value.has_local_data()) { 685 output += indent + " local_data: "; 686 base::StringAppendF(&output, "%s", GetProtoDebugStringWithIndent( 687 value.local_data(), indent_size + 2) 688 .c_str()); 689 output += "\n"; 690 } 691 if (value.has_dictionary_attack_counter()) { 692 output += indent + " dictionary_attack_counter: "; 693 base::StringAppendF(&output, "%u (0x%08X)", 694 value.dictionary_attack_counter(), 695 value.dictionary_attack_counter()); 696 output += "\n"; 697 } 698 if (value.has_dictionary_attack_threshold()) { 699 output += indent + " dictionary_attack_threshold: "; 700 base::StringAppendF(&output, "%u (0x%08X)", 701 value.dictionary_attack_threshold(), 702 value.dictionary_attack_threshold()); 703 output += "\n"; 704 } 705 if (value.has_dictionary_attack_lockout_in_effect()) { 706 output += indent + " dictionary_attack_lockout_in_effect: "; 707 base::StringAppendF( 708 &output, "%s", 709 value.dictionary_attack_lockout_in_effect() ? "true" : "false"); 710 output += "\n"; 711 } 712 if (value.has_dictionary_attack_lockout_seconds_remaining()) { 713 output += indent + " dictionary_attack_lockout_seconds_remaining: "; 714 base::StringAppendF(&output, "%u (0x%08X)", 715 value.dictionary_attack_lockout_seconds_remaining(), 716 value.dictionary_attack_lockout_seconds_remaining()); 717 output += "\n"; 718 } 719 output += indent + "}\n"; 720 return output; 721 } 722 723 std::string GetProtoDebugString(const TakeOwnershipRequest& value) { 724 return GetProtoDebugStringWithIndent(value, 0); 725 } 726 727 std::string GetProtoDebugStringWithIndent(const TakeOwnershipRequest& value, 728 int indent_size) { 729 std::string indent(indent_size, ' '); 730 std::string output = 731 base::StringPrintf("[%s] {\n", value.GetTypeName().c_str()); 732 733 output += indent + "}\n"; 734 return output; 735 } 736 737 std::string GetProtoDebugString(const TakeOwnershipReply& value) { 738 return GetProtoDebugStringWithIndent(value, 0); 739 } 740 741 std::string GetProtoDebugStringWithIndent(const TakeOwnershipReply& value, 742 int indent_size) { 743 std::string indent(indent_size, ' '); 744 std::string output = 745 base::StringPrintf("[%s] {\n", value.GetTypeName().c_str()); 746 747 if (value.has_status()) { 748 output += indent + " status: "; 749 base::StringAppendF( 750 &output, "%s", 751 GetProtoDebugStringWithIndent(value.status(), indent_size + 2).c_str()); 752 output += "\n"; 753 } 754 output += indent + "}\n"; 755 return output; 756 } 757 758 std::string GetProtoDebugString(const RemoveOwnerDependencyRequest& value) { 759 return GetProtoDebugStringWithIndent(value, 0); 760 } 761 762 std::string GetProtoDebugStringWithIndent( 763 const RemoveOwnerDependencyRequest& value, 764 int indent_size) { 765 std::string indent(indent_size, ' '); 766 std::string output = 767 base::StringPrintf("[%s] {\n", value.GetTypeName().c_str()); 768 769 if (value.has_owner_dependency()) { 770 output += indent + " owner_dependency: "; 771 base::StringAppendF(&output, "%s", 772 base::HexEncode(value.owner_dependency().data(), 773 value.owner_dependency().size()) 774 .c_str()); 775 output += "\n"; 776 } 777 output += indent + "}\n"; 778 return output; 779 } 780 781 std::string GetProtoDebugString(const RemoveOwnerDependencyReply& value) { 782 return GetProtoDebugStringWithIndent(value, 0); 783 } 784 785 std::string GetProtoDebugStringWithIndent( 786 const RemoveOwnerDependencyReply& value, 787 int indent_size) { 788 std::string indent(indent_size, ' '); 789 std::string output = 790 base::StringPrintf("[%s] {\n", value.GetTypeName().c_str()); 791 792 if (value.has_status()) { 793 output += indent + " status: "; 794 base::StringAppendF( 795 &output, "%s", 796 GetProtoDebugStringWithIndent(value.status(), indent_size + 2).c_str()); 797 output += "\n"; 798 } 799 output += indent + "}\n"; 800 return output; 801 } 802 803 } // namespace tpm_manager 804