mirror of
https://git.sr.ht/~nabijaczleweli/tzpfms
synced 2025-04-17 09:42:19 +03:00
Actually copy in the CreatePrimary parameters to the right slots
This mimicks tpm2-tools; I don't think it matters any, since I'm pretty sure these are just unused for our application, but
This commit is contained in:
parent
b811862e0a
commit
d950de0ae4
@ -197,9 +197,7 @@ static int get_key_material_raw(const char * whom, bool again, bool newkey, uint
|
||||
// Read the key material
|
||||
size_t buflen{};
|
||||
errno = 0;
|
||||
printf("pretline buf=%s (%p); bl=%d\n", buf, (void *)buf, (int)buflen);
|
||||
auto bytes = getline((char **)&buf, &buflen, stdin);
|
||||
printf("\ngetline returned: %d; errnp=%d; buf=%s (%p); bl=%d\n\n", (int)bytes, errno, buf, (void *)buf, (int)buflen);
|
||||
switch(bytes) {
|
||||
case -1:
|
||||
if(errno != 0)
|
||||
@ -258,7 +256,6 @@ int read_new_passphrase(const char * whom, uint8_t *& buf, size_t & len_out, siz
|
||||
TRY_MAIN(get_key_material_dispatch(whom, false, true, first_passphrase, first_passphrase_len));
|
||||
quickscope_wrapper first_passphrase_deleter{[&] { free(first_passphrase); }};
|
||||
|
||||
printf("fp=%s; fps=%zu\n", first_passphrase, first_passphrase_len);
|
||||
if(first_passphrase_len != 0 && first_passphrase_len < MIN_PASSPHRASE_LEN)
|
||||
return fprintf(stderr, "Passphrase too short (min %u)\n", MIN_PASSPHRASE_LEN), __LINE__;
|
||||
if(first_passphrase_len > max_len)
|
||||
@ -272,7 +269,6 @@ printf("fp=%s; fps=%zu\n", first_passphrase, first_passphrase_len);
|
||||
if(second_passphrase_len != first_passphrase_len || memcmp(first_passphrase, second_passphrase, first_passphrase_len))
|
||||
return fprintf(stderr, "Provided keys do not match.\n"), __LINE__;
|
||||
|
||||
printf("sp=%s; sps=%zu\n", second_passphrase, second_passphrase_len);
|
||||
if(second_passphrase_len) {
|
||||
buf = second_passphrase;
|
||||
second_passphrase = nullptr;
|
||||
|
@ -335,6 +335,10 @@ int tpm2_seal(const char * dataset, ESYS_CONTEXT * tpm2_ctx, ESYS_TR tpm2_sessio
|
||||
pub.publicArea.parameters.rsaDetail.scheme.scheme = TPM2_ALG_NULL;
|
||||
pub.publicArea.parameters.rsaDetail.keyBits = 2048;
|
||||
pub.publicArea.parameters.rsaDetail.exponent = 0;
|
||||
pub.publicArea.parameters.asymDetail.scheme.scheme = TPM2_ALG_NULL;
|
||||
pub.publicArea.parameters.symDetail.sym.algorithm = TPM2_ALG_AES;
|
||||
pub.publicArea.parameters.symDetail.sym.keyBits.sym = 128;
|
||||
pub.publicArea.parameters.symDetail.sym.mode.sym = TPM2_ALG_CFB;
|
||||
TRY_MAIN(try_or_passphrase("create primary encryption key", "TPM2 owner hierarchy", tpm2_ctx, TPM2_RC_BAD_AUTH, ESYS_TR_RH_OWNER, [&] {
|
||||
return Esys_CreatePrimary(tpm2_ctx, ESYS_TR_RH_OWNER, tpm2_session, ESYS_TR_NONE, ESYS_TR_NONE, &primary_sens, &pub, &metadata, &pcrs, &primary_handle,
|
||||
nullptr, nullptr, nullptr, nullptr);
|
||||
|
Loading…
x
Reference in New Issue
Block a user