14 changes: 7 additions & 7 deletions tools/tpm2_getpubek.c
Expand Up @@ -38,10 +38,10 @@

#include <sapi/tpm20.h>

#include "../lib/tpm2_password_util.h"
#include "files.h"
#include "log.h"
#include "main.h"
#include "password_util.h"
#include "tpm2_util.h"
#include "tpm2_alg_util.h"

Expand Down Expand Up @@ -182,13 +182,13 @@ static bool create_ek_handle(getpubek_context *ctx) {
sessionsDataOut.rspAuthsCount = 1;
sessionsData.cmdAuthsCount = 1;

bool result = password_tpm2_util_to_auth(&ctx->passwords.endorse,
bool result = tpm2_password_util_fromhex(&ctx->passwords.endorse,
ctx->passwords.is_hex, "endorse", &sessionData.hmac);
if (!result) {
return false;
}

result = password_tpm2_util_to_auth(&ctx->passwords.ek, ctx->passwords.is_hex,
result = tpm2_password_util_fromhex(&ctx->passwords.ek, ctx->passwords.is_hex,
"ek", &inSensitive.t.sensitive.userAuth);
if (!result) {
return false;
Expand Down Expand Up @@ -219,7 +219,7 @@ static bool create_ek_handle(getpubek_context *ctx) {

// To make EK persistent, use own auth
sessionData.hmac.t.size = 0;
result = password_tpm2_util_to_auth(&ctx->passwords.owner, ctx->passwords.is_hex,
result = tpm2_password_util_fromhex(&ctx->passwords.owner, ctx->passwords.is_hex,
"owner", &sessionData.hmac);
if (!result) {
return false;
Expand Down Expand Up @@ -296,21 +296,21 @@ static bool init(int argc, char *argv[], char *envp[], getpubek_context *ctx) {
break;

case 'e':
result = password_tpm2_util_copy_password(optarg, "endorsement password",
result = tpm2_password_util_copy_password(optarg, "endorsement password",
&ctx->passwords.endorse);
if (!result) {
return false;
}
break;
case 'o':
result = password_tpm2_util_copy_password(optarg, "owner password",
result = tpm2_password_util_copy_password(optarg, "owner password",
&ctx->passwords.owner);
if (!result) {
return false;
}
break;
case 'P':
result = password_tpm2_util_copy_password(optarg, "EK password", &ctx->passwords.ek);
result = tpm2_password_util_copy_password(optarg, "EK password", &ctx->passwords.ek);
if (!result) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion tools/tpm2_getrandom.c
Expand Up @@ -38,11 +38,11 @@
#include <limits.h>
#include <sapi/tpm20.h>

#include "../lib/tpm2_password_util.h"
#include "log.h"
#include "files.h"
#include "main.h"
#include "options.h"
#include "password_util.h"
#include "tpm2_util.h"

typedef struct tpm_random_ctx tpm_random_ctx;
Expand Down
6 changes: 3 additions & 3 deletions tools/tpm2_hmac.c
Expand Up @@ -38,12 +38,12 @@
#include <limits.h>
#include <sapi/tpm20.h>

#include "../lib/tpm2_password_util.h"
#include "tpm2_util.h"
#include "log.h"
#include "files.h"
#include "main.h"
#include "options.h"
#include "password_util.h"
#include "tpm2_alg_util.h"

typedef struct tpm_hmac_ctx tpm_hmac_ctx;
Expand Down Expand Up @@ -159,7 +159,7 @@ static bool init(int argc, char *argv[], tpm_hmac_ctx *ctx) {
flags.k = 1;
break;
case 'P':
result = password_tpm2_util_copy_password(optarg, "key handle",
result = tpm2_password_util_copy_password(optarg, "key handle",
&ctx->session_data.hmac);
if (!result) {
return false;
Expand Down Expand Up @@ -242,7 +242,7 @@ static bool init(int argc, char *argv[], tpm_hmac_ctx *ctx) {
}

/* convert a hex password if needed */
return password_tpm2_util_to_auth(&ctx->session_data.hmac, is_hex_passwd,
return tpm2_password_util_fromhex(&ctx->session_data.hmac, is_hex_passwd,
"key handle", &ctx->session_data.hmac);
}

Expand Down
4 changes: 2 additions & 2 deletions tools/tpm2_load.c
Expand Up @@ -41,9 +41,9 @@

#include <sapi/tpm20.h>

#include "../lib/tpm2_password_util.h"
#include "log.h"
#include "tpm2_util.h"
#include "password_util.h"
#include "files.h"
#include "main.h"
#include "options.h"
Expand Down Expand Up @@ -166,7 +166,7 @@ execute_tool (int argc,
H_flag = 1;
break;
case 'P':
if(!password_tpm2_util_copy_password(optarg, "parent key", &sessionData.hmac))
if(!tpm2_password_util_copy_password(optarg, "parent key", &sessionData.hmac))
{
return 1;
}
Expand Down
10 changes: 5 additions & 5 deletions tools/tpm2_nvdefine.c
Expand Up @@ -38,11 +38,11 @@

#include <sapi/tpm20.h>

#include "../lib/tpm2_password_util.h"
#include "files.h"
#include "log.h"
#include "main.h"
#include "options.h"
#include "password_util.h"
#include "tpm2_nv_util.h"
#include "tpm2_util.h"

Expand Down Expand Up @@ -93,7 +93,7 @@ static int nv_space_define(tpm_nvdefine_ctx *ctx) {
sessions_data_out.rspAuthsCount = 1;
sessions_data.cmdAuthsCount = 1;

bool result = password_tpm2_util_to_auth(&ctx->handlePasswd, ctx->hexPasswd,
bool result = tpm2_password_util_fromhex(&ctx->handlePasswd, ctx->hexPasswd,
"handle password", &session_data.hmac);
if (!result) {
return false;
Expand All @@ -117,7 +117,7 @@ static int nv_space_define(tpm_nvdefine_ctx *ctx) {
public_info.t.nvPublic.dataSize = ctx->size;

TPM2B_AUTH nvAuth;
result = password_tpm2_util_to_auth(&ctx->indexPasswd, ctx->hexPasswd,
result = tpm2_password_util_fromhex(&ctx->indexPasswd, ctx->hexPasswd,
"index password", &nvAuth);
if (!result) {
return false;
Expand Down Expand Up @@ -190,7 +190,7 @@ static bool init(int argc, char* argv[], tpm_nvdefine_ctx *ctx) {
}
break;
case 'P':
result = password_tpm2_util_copy_password(optarg, "handle password",
result = tpm2_password_util_copy_password(optarg, "handle password",
&ctx->handlePasswd);
if (!result) {
return false;
Expand All @@ -216,7 +216,7 @@ static bool init(int argc, char* argv[], tpm_nvdefine_ctx *ctx) {
}
break;
case 'I':
result = password_tpm2_util_copy_password(optarg, "index password",
result = tpm2_password_util_copy_password(optarg, "index password",
&ctx->indexPasswd);
if (!result) {
return false;
Expand Down
6 changes: 3 additions & 3 deletions tools/tpm2_nvread.c
Expand Up @@ -38,10 +38,10 @@

#include <sapi/tpm20.h>

#include "../lib/tpm2_password_util.h"
#include "log.h"
#include "main.h"
#include "options.h"
#include "password_util.h"
#include "tpm2_nv_util.h"
#include "tpm2_util.h"

Expand Down Expand Up @@ -108,7 +108,7 @@ static bool nv_read(tpm_nvread_ctx *ctx) {
session_data.sessionHandle = ctx->auth_session_handle;
}

bool result = password_tpm2_util_to_auth(&ctx->handle_passwd, ctx->is_hex_password,
bool result = tpm2_password_util_fromhex(&ctx->handle_passwd, ctx->is_hex_password,
"handle password", &session_data.hmac);
if (!result) {
return false;
Expand Down Expand Up @@ -228,7 +228,7 @@ static bool init(int argc, char *argv[], tpm_nvread_ctx *ctx) {
}
break;
case 'P':
result = password_tpm2_util_copy_password(optarg, "handle password",
result = tpm2_password_util_copy_password(optarg, "handle password",
&ctx->handle_passwd);
if (!result) {
return false;
Expand Down
6 changes: 3 additions & 3 deletions tools/tpm2_nvreadlock.c
Expand Up @@ -39,10 +39,10 @@

#include <sapi/tpm20.h>

#include "../lib/tpm2_password_util.h"
#include "log.h"
#include "main.h"
#include "options.h"
#include "password_util.h"
#include "tpm2_util.h"

typedef struct tpm_nvreadlock_ctx tpm_nvreadlock_ctx;
Expand Down Expand Up @@ -87,7 +87,7 @@ static bool nv_readlock(tpm_nvreadlock_ctx *ctx) {
sessions_data_out.rspAuthsCount = 1;
sessions_data.cmdAuthsCount = 1;

bool result = password_tpm2_util_to_auth(&ctx->handle_passwd, ctx->is_hex_passwd,
bool result = tpm2_password_util_fromhex(&ctx->handle_passwd, ctx->is_hex_passwd,
"handle password", &session_data.hmac);
if (!result) {
return false;
Expand Down Expand Up @@ -155,7 +155,7 @@ static bool init(int argc, char *argv[], tpm_nvreadlock_ctx *ctx) {
}
break;
case 'P':
result = password_tpm2_util_copy_password(optarg, "handle password",
result = tpm2_password_util_copy_password(optarg, "handle password",
&ctx->handle_passwd);
if (!result) {
return false;
Expand Down
6 changes: 3 additions & 3 deletions tools/tpm2_nvrelease.c
Expand Up @@ -37,10 +37,10 @@

#include <sapi/tpm20.h>

#include "../lib/tpm2_password_util.h"
#include "log.h"
#include "main.h"
#include "options.h"
#include "password_util.h"
#include "tpm2_util.h"

typedef struct tpm_nvrelease_ctx tpm_nvrelease_ctx;
Expand Down Expand Up @@ -74,7 +74,7 @@ static bool nv_space_release(tpm_nvrelease_ctx *ctx) {
sessions_data.cmdAuths = &session_data_array[0];
sessions_data.cmdAuthsCount = 1;

bool result = password_tpm2_util_to_auth(&ctx->handle_passwd,
bool result = tpm2_password_util_fromhex(&ctx->handle_passwd,
ctx->is_hex_password, "handle password", &session_data.hmac);
if (!result) {
return false;
Expand Down Expand Up @@ -146,7 +146,7 @@ static bool init(int argc, char* argv[], tpm_nvrelease_ctx *ctx) {
ctx->is_auth_session = true;
break;
case 'P':
result = password_tpm2_util_copy_password(optarg, "handle password",
result = tpm2_password_util_copy_password(optarg, "handle password",
&ctx->handle_passwd);
if (!result) {
return false;
Expand Down
6 changes: 3 additions & 3 deletions tools/tpm2_nvwrite.c
Expand Up @@ -39,11 +39,11 @@

#include <sapi/tpm20.h>

#include "../lib/tpm2_password_util.h"
#include "log.h"
#include "files.h"
#include "main.h"
#include "options.h"
#include "password_util.h"
#include "tpm2_util.h"

typedef struct tpm_nvwrite_ctx tpm_nvwrite_ctx;
Expand Down Expand Up @@ -87,7 +87,7 @@ static int nv_write(tpm_nvwrite_ctx *ctx) {
sessions_data_out.rspAuthsCount = 1;
sessions_data.cmdAuthsCount = 1;

bool result = password_tpm2_util_to_auth(&ctx->handle_passwd, ctx->hex_passwd,
bool result = tpm2_password_util_fromhex(&ctx->handle_passwd, ctx->hex_passwd,
"handle password", &session_data.hmac);
if (!result) {
return false;
Expand Down Expand Up @@ -176,7 +176,7 @@ static bool init(int argc, char *argv[], tpm_nvwrite_ctx *ctx) {
ctx->input_file = optarg;
break;
case 'P':
result = password_tpm2_util_copy_password(optarg, "handle password",
result = tpm2_password_util_copy_password(optarg, "handle password",
&ctx->handle_passwd);
if (!result) {
return false;
Expand Down
4 changes: 2 additions & 2 deletions tools/tpm2_quote.c
Expand Up @@ -42,8 +42,8 @@
#include <sapi/tpm20.h>
#include <tcti/tcti_socket.h>

#include "../lib/tpm2_password_util.h"
#include "tpm2_util.h"
#include "password_util.h"
#include "files.h"
#include "log.h"
#include "main.h"
Expand Down Expand Up @@ -363,7 +363,7 @@ int execute_tool (int argc, char *argv[], char *envp[], common_opts_t *opts,
break;

case 'P':
if(!password_tpm2_util_copy_password(optarg, "parent key", &sessionData.hmac))
if(!tpm2_password_util_copy_password(optarg, "parent key", &sessionData.hmac))
{
showArgError(optarg, argv[0]);
return 1;
Expand Down
2 changes: 1 addition & 1 deletion tools/tpm2_readpublic.c
Expand Up @@ -38,11 +38,11 @@
#include <getopt.h>
#include <sapi/tpm20.h>

#include "../lib/tpm2_password_util.h"
#include "files.h"
#include "log.h"
#include "main.h"
#include "options.h"
#include "password_util.h"
#include "tpm2_util.h"

typedef struct tpm_readpub_ctx tpm_readpub_ctx;
Expand Down
6 changes: 3 additions & 3 deletions tools/tpm2_rsadecrypt.c
Expand Up @@ -38,11 +38,11 @@
#include <getopt.h>
#include <sapi/tpm20.h>

#include "../lib/tpm2_password_util.h"
#include "files.h"
#include "log.h"
#include "main.h"
#include "options.h"
#include "password_util.h"
#include "tpm2_util.h"

typedef struct tpm_rsadecrypt_ctx tpm_rsadecrypt_ctx;
Expand Down Expand Up @@ -136,7 +136,7 @@ static bool init(int argc, char *argv[], tpm_rsadecrypt_ctx *ctx) {
}
break;
case 'P': {
bool result = password_tpm2_util_copy_password(optarg, "key",
bool result = tpm2_password_util_copy_password(optarg, "key",
&ctx->session_data.hmac);
if (!result) {
return false;
Expand Down Expand Up @@ -201,7 +201,7 @@ static bool init(int argc, char *argv[], tpm_rsadecrypt_ctx *ctx) {
}
}

return password_tpm2_util_to_auth(&ctx->session_data.hmac, is_hex_passwd,
return tpm2_password_util_fromhex(&ctx->session_data.hmac, is_hex_passwd,
"key", &ctx->session_data.hmac);
}

Expand Down
6 changes: 3 additions & 3 deletions tools/tpm2_sign.c
Expand Up @@ -38,11 +38,11 @@
#include <getopt.h>
#include <sapi/tpm20.h>

#include "../lib/tpm2_password_util.h"
#include "files.h"
#include "log.h"
#include "main.h"
#include "options.h"
#include "password_util.h"
#include "tpm2_util.h"
#include "tpm_hash.h"
#include "tpm2_alg_util.h"
Expand Down Expand Up @@ -223,7 +223,7 @@ static bool init(int argc, char *argv[], tpm_sign_ctx *ctx) {
}
break;
case 'P': {
bool result = password_tpm2_util_copy_password(optarg, "key",
bool result = tpm2_password_util_copy_password(optarg, "key",
&ctx->sessionData.hmac);
if (!result) {
return false;
Expand Down Expand Up @@ -300,7 +300,7 @@ static bool init(int argc, char *argv[], tpm_sign_ctx *ctx) {
ctx->validation.hierarchy = TPM_RH_NULL;
}

bool result = password_tpm2_util_to_auth(&ctx->sessionData.hmac, hexPasswd,
bool result = tpm2_password_util_fromhex(&ctx->sessionData.hmac, hexPasswd,
"key", &ctx->sessionData.hmac);
if (!result) {
return false;
Expand Down
18 changes: 9 additions & 9 deletions tools/tpm2_takeownership.c
Expand Up @@ -44,7 +44,7 @@
#include "log.h"
#include "options.h"
#include "main.h"
#include "password_util.h"
#include "tpm2_password_util.h"
#include "tpm2_util.h"

typedef struct password password;
Expand Down Expand Up @@ -79,7 +79,7 @@ bool clear_hierarchy_auth(takeownership_ctx *ctx) {
sessionsData.cmdAuths = &sessionDataArray[0];
sessionsData.cmdAuthsCount = 1;

bool result = password_tpm2_util_to_auth(&ctx->passwords.lockout.old, ctx->is_hex_passwords, "old lockout", &sessionData.hmac);
bool result = tpm2_password_util_fromhex(&ctx->passwords.lockout.old, ctx->is_hex_passwords, "old lockout", &sessionData.hmac);
if (!result) {
return false;
}
Expand All @@ -102,7 +102,7 @@ static bool gen_tpm2b_auth(TPM2B_AUTH *passwd, bool is_hex_password,
// unique identifier for error reporting
snprintf(desc, sizeof(desc), "%s %s", old_new, description);

return password_tpm2_util_to_auth(passwd, is_hex_password, desc, auth);
return tpm2_password_util_fromhex(passwd, is_hex_password, desc, auth);
}

static bool change_auth(TSS2_SYS_CONTEXT *sapi_context,
Expand Down Expand Up @@ -209,42 +209,42 @@ static bool init(int argc, char *argv[], char *envp[], takeownership_ctx *ctx,
break;

case 'o':
result = password_tpm2_util_copy_password(optarg, "new owner password",
result = tpm2_password_util_copy_password(optarg, "new owner password",
&ctx->passwords.owner.new);
if (!result) {
return false;
}
break;
case 'e':
result = password_tpm2_util_copy_password(optarg, "new endorse password",
result = tpm2_password_util_copy_password(optarg, "new endorse password",
&ctx->passwords.endorse.new);
if (!result) {
return false;
}
break;
case 'l':
result = password_tpm2_util_copy_password(optarg, "new lockout password",
result = tpm2_password_util_copy_password(optarg, "new lockout password",
&ctx->passwords.lockout.new);
if (!result) {
return false;
}
break;
case 'O':
result = password_tpm2_util_copy_password(optarg, "current owner password",
result = tpm2_password_util_copy_password(optarg, "current owner password",
&ctx->passwords.owner.old);
if (!result) {
return false;
}
break;
case 'E':
result = password_tpm2_util_copy_password(optarg, "current endorse password",
result = tpm2_password_util_copy_password(optarg, "current endorse password",
&ctx->passwords.endorse.old);
if (!result) {
return false;
}
break;
case 'L':
result = password_tpm2_util_copy_password(optarg, "current lockout password",
result = tpm2_password_util_copy_password(optarg, "current lockout password",
&ctx->passwords.lockout.old);
if (!result) {
return false;
Expand Down
6 changes: 3 additions & 3 deletions tools/tpm2_unseal.c
Expand Up @@ -38,11 +38,11 @@
#include <getopt.h>
#include <sapi/tpm20.h>

#include "../lib/tpm2_password_util.h"
#include "files.h"
#include "log.h"
#include "main.h"
#include "options.h"
#include "password_util.h"
#include "pcr.h"
#include "tpm2_policy.h"
#include "tpm2_util.h"
Expand Down Expand Up @@ -142,7 +142,7 @@ static bool init(int argc, char *argv[], tpm_unseal_ctx *ctx) {
}
break;
case 'P': {
bool result = password_tpm2_util_copy_password(optarg, "key",
bool result = tpm2_password_util_copy_password(optarg, "key",
&ctx->sessionData.hmac);
if (!result) {
return false;
Expand Down Expand Up @@ -204,7 +204,7 @@ static bool init(int argc, char *argv[], tpm_unseal_ctx *ctx) {
}

if (flags.P) {
bool result = password_tpm2_util_to_auth(&ctx->sessionData.hmac, hexPasswd,
bool result = tpm2_password_util_fromhex(&ctx->sessionData.hmac, hexPasswd,
"key", &ctx->sessionData.hmac);
if (!result) {
return false;
Expand Down