OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 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 // TPM client for initialization |
| 6 |
| 7 #include <base/command_line.h> |
| 8 #include <iostream> |
| 9 |
| 10 #include "secure_blob.h" |
| 11 #include "tpm.h" |
| 12 |
| 13 namespace switches { |
| 14 static const char kActionSwitch[] = "action"; |
| 15 static const char *kActions[] = { |
| 16 "initialize", |
| 17 NULL }; |
| 18 enum ActionEnum { |
| 19 ACTION_INITIALIZE }; |
| 20 } // namespace switches |
| 21 |
| 22 int main(int argc, char **argv) { |
| 23 CommandLine::Init(argc, argv); |
| 24 |
| 25 CommandLine *cl = CommandLine::ForCurrentProcess(); |
| 26 std::string action = cl->GetSwitchValueASCII(switches::kActionSwitch); |
| 27 |
| 28 if (!strcmp(switches::kActions[switches::ACTION_INITIALIZE], |
| 29 action.c_str())) { |
| 30 tpm_init::Tpm tpm; |
| 31 tpm.Init(); |
| 32 if (tpm.InitializeTpm()) { |
| 33 tpm_init::SecureBlob password; |
| 34 tpm.GetOwnerPassword(&password); |
| 35 std::string str_password(static_cast<const char*>(password.const_data()), |
| 36 password.size()); |
| 37 printf("TPM Owner Password: %s\n", str_password.c_str()); |
| 38 } else { |
| 39 printf("Failed to initialize the TPM\n"); |
| 40 } |
| 41 } else { |
| 42 printf("Unknown action or no action given. Available actions: \n"); |
| 43 for(int i = 0; /* loop forever */; i++) { |
| 44 if(!switches::kActions[i]) { |
| 45 break; |
| 46 } |
| 47 printf(" --action=%s\n", switches::kActions[i]); |
| 48 } |
| 49 } |
| 50 return 0; |
| 51 } |
OLD | NEW |