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

Side by Side Diff: main.cc

Issue 3048029: Initial version of tpm_init, a library for taking ownership of the TPM. (Closed) Base URL: ssh://git@chromiumos-git/tpm_init.git
Patch Set: Minor fix to the error code check from TakeOwnership. Created 10 years, 4 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 | « crypto.cc ('k') | secure_blob.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « crypto.cc ('k') | secure_blob.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698