diff options
author | James Bottomley <James.Bottomley@HansenPartnership.com> | 2018-06-29 17:42:27 -0700 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2018-06-29 17:42:27 -0700 |
commit | 8763f3c14fb82bb910c99c3db5e46ebc42526315 (patch) | |
tree | 3e92666efcc53818c96c7508e513bb9d6c5f7e14 | |
parent | 4ee4b9e65ad5c5bb6d0f076602719dc480d45e17 (diff) | |
download | openssl_tpm2_engine-8763f3c14fb82bb910c99c3db5e46ebc42526315.tar.gz |
create_tpm2_key: fix ordering of password collection and policy file parsing
The current order goes collect auth first before parsing the policy
file which leads to the unfortunate consequence that we'll make you
type in a verified password before we error out and tell you you don't
have the correct PolicyAuthValue command in your policy file. Reorder
this so we only collect the password after we've verified the policy
correctly supports it.
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
-rw-r--r-- | create_tpm2_key.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/create_tpm2_key.c b/create_tpm2_key.c index dc89199..9845520 100644 --- a/create_tpm2_key.c +++ b/create_tpm2_key.c @@ -726,18 +726,6 @@ int main(int argc, char **argv) rsa = 0; } - if (auth) { - if (key) { - /* key length already checked */ - strcpy(auth, key); - } else { - if (EVP_read_pw_string(auth, 128, "Enter TPM key authority: ", 1)) { - fprintf(stderr, "Passwords do not match\n"); - exit(1); - } - } - } - dir = tpm2_set_unique_tssdir(); rc = tpm2_create(&tssContext, dir); if (rc) { @@ -774,6 +762,20 @@ int main(int argc, char **argv) } } + if (auth) { + if (key) { + /* key length already checked */ + strcpy(auth, key); + } else { + if (EVP_read_pw_string(auth, 128, "Enter TPM key authority: ", 1)) { + fprintf(stderr, "Passwords do not match\n"); + reason = "authorization"; + rc = NOT_TPM_ERROR; + goto out_flush; + } + } + } + if (wrap) { Import_In iin; Import_Out iout; |