Skip to content

Commit

Permalink
tpm2_nvreadlock: update -S to session file
Browse files Browse the repository at this point in the history
Signed-off-by: William Roberts <william.c.roberts@intel.com>
  • Loading branch information
William Roberts committed Jan 14, 2018
1 parent 82ae37b commit b643631
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions tools/tpm2_nvreadlock.c
@@ -1,5 +1,5 @@
//**********************************************************************;
// Copyright (c) 2015, Intel Corporation
// Copyright (c) 2015-2018, Intel Corporation
// Copyright (c) 2016, Atom Software Studios
// All rights reserved.
//
Expand Down Expand Up @@ -38,9 +38,10 @@

#include <sapi/tpm20.h>

#include "log.h"
#include "tpm2_options.h"
#include "tpm2_password_util.h"
#include "log.h"
#include "tpm2_session.h"
#include "tpm2_tool.h"
#include "tpm2_util.h"

Expand Down Expand Up @@ -113,13 +114,15 @@ static bool on_option(char key, char *value) {
return false;
}
break;
case 'S':
if (!tpm2_util_string_to_uint32(value, &ctx.session_data.sessionHandle)) {
LOG_ERR("Could not convert session handle to number, got: \"%s\"",
value);
case 'S': {
tpm2_session *s = tpm2_session_restore(value);
if (!s) {
return false;
}
break;

ctx.session_data.sessionHandle = tpm2_session_get_handle(s);
tpm2_session_free(&s);
} break;
}

return true;
Expand All @@ -132,7 +135,7 @@ bool tpm2_tool_onstart(tpm2_options **opts) {
{ "auth-handle", required_argument, NULL, 'a' },
{ "handle-passwd", required_argument, NULL, 'P' },
{ "passwdInHex", no_argument, NULL, 'X' },
{ "input-session-handle", required_argument, NULL, 'S' },
{ "session", required_argument, NULL, 'S' },
};

*opts = tpm2_options_new("x:a:P:Xp:d:S:hv", ARRAY_LEN(topts), topts,
Expand Down

0 comments on commit b643631

Please sign in to comment.