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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « crypto.cc ('k') | secure_blob.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: main.cc
diff --git a/main.cc b/main.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0deda46062613aa6c758f6b9886865a82a3a8f79
--- /dev/null
+++ b/main.cc
@@ -0,0 +1,51 @@
+// Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// TPM client for initialization
+
+#include <base/command_line.h>
+#include <iostream>
+
+#include "secure_blob.h"
+#include "tpm.h"
+
+namespace switches {
+ static const char kActionSwitch[] = "action";
+ static const char *kActions[] = {
+ "initialize",
+ NULL };
+ enum ActionEnum {
+ ACTION_INITIALIZE };
+} // namespace switches
+
+int main(int argc, char **argv) {
+ CommandLine::Init(argc, argv);
+
+ CommandLine *cl = CommandLine::ForCurrentProcess();
+ std::string action = cl->GetSwitchValueASCII(switches::kActionSwitch);
+
+ if (!strcmp(switches::kActions[switches::ACTION_INITIALIZE],
+ action.c_str())) {
+ tpm_init::Tpm tpm;
+ tpm.Init();
+ if (tpm.InitializeTpm()) {
+ tpm_init::SecureBlob password;
+ tpm.GetOwnerPassword(&password);
+ std::string str_password(static_cast<const char*>(password.const_data()),
+ password.size());
+ printf("TPM Owner Password: %s\n", str_password.c_str());
+ } else {
+ printf("Failed to initialize the TPM\n");
+ }
+ } else {
+ printf("Unknown action or no action given. Available actions: \n");
+ for(int i = 0; /* loop forever */; i++) {
+ if(!switches::kActions[i]) {
+ break;
+ }
+ printf(" --action=%s\n", switches::kActions[i]);
+ }
+ }
+ return 0;
+}
« 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