Skip to content

Commit

Permalink
tpm2_createprimary: 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 af5e24c commit e51cfe2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
5 changes: 3 additions & 2 deletions man/tpm2_createprimary.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ will create and load a Primary Object. The sensitive area is not returned.

`TPMA_OBJECT_RESTRICTED|TPMA_OBJECT_DECRYPT|TPMA_OBJECT_FIXEDTPM|TPMA_OBJECT_FIXEDPARENT|TPMA_OBJECT_SENSITIVEDATAORIGIN|TPMA_OBJECT_USERWITHAUTH`

* **-S**, **--input-session-handle**=_SESSION\_HANDLE_:
Optional Input session handle from a policy session for authorization.
* **-S**, **--session**=_SESSION\_FILE_:

Optional, A session file from **tpm2_startauthsession**(1)'s **-S** option.

[common options](common/options.md)

Expand Down
15 changes: 9 additions & 6 deletions tools/tpm2_createprimary.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//**********************************************************************;
// Copyright (c) 2015, Intel Corporation
// Copyright (c) 2015-2018, Intel Corporation
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -47,6 +47,7 @@
#include "tpm2_attr_util.h"
#include "tpm2_options.h"
#include "tpm2_password_util.h"
#include "tpm2_session.h"
#include "tpm2_tool.h"
#include "tpm2_util.h"

Expand Down Expand Up @@ -281,13 +282,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 Down

0 comments on commit e51cfe2

Please sign in to comment.