Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix errors identified in tpm2-software#140
Browse files Browse the repository at this point in the history
Signed-off-by: Petr Gotthard <[email protected]>
gotthardp committed Oct 24, 2020
1 parent 93f94d6 commit d966c89
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/tpm2-tss-engine-common.c
Original file line number Diff line number Diff line change
@@ -597,12 +597,14 @@ init_tpm_key (ESYS_CONTEXT **esys_ctx, ESYS_TR *keyHandle, TPM2_DATA *tpm2Data)
*
* Read a tpm key as marshaled TPM2B_PUBLIC and (encrypted) TPM2B_PRIVATE from
* disk and convert them into a TPM2_DATA representation
* @param filename The filename to read the data from.
* @param filenamepub The filename to read the public portion from.
* @param filenametpm The filename to read the private portion from.
* @param parent Handle of the parent key.
* @param emptyAuth Whether the object does not require authentication.
* @param tpm2Datap The data after read.
* @retval 1 on success
* @retval 0 on failure
*/
//TODO: all the Errors !!!
int
tpm2tss_tpm2data_importtpm(const char *filenamepub, const char *filenametpm,
TPM2_HANDLE parent, int emptyAuth,
@@ -639,8 +641,8 @@ tpm2tss_tpm2data_importtpm(const char *filenamepub, const char *filenametpm,
}

tpm2data = OPENSSL_malloc(sizeof(TPM2_DATA));
if (!tpm2data)
return 0;
if (!tpm2data)
return 0;

memset(tpm2data, 0, sizeof(*tpm2data));
tpm2data->privatetype = KEY_TYPE_BLOB;
4 changes: 2 additions & 2 deletions src/tpm2tss-genkey.c
Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ char *help =
" -v, --verbose print verbose messages\n"
" -W, --parentpw password for the parent key (default: none)\n"
" -t, --tcti tcti configuration string (default: none)\n"
"\n";
"\n";

static const char *optstr = "a:c:e:hi:k:o:p:P:s:vW:t:";

@@ -222,7 +222,7 @@ parse_opts(int argc, char **argv)
exit(1);
}

if (opt.importpub && !opt.importtpm) {
if ((opt.importpub && !opt.importtpm) || (!opt.importpub && opt.importtpm)) {
ERR("--importpub requires --importtpm");
return 1;
}

0 comments on commit d966c89

Please sign in to comment.