From b811862e0a76a162ffa54d2add893b0bc3c6fd13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 3 Dec 2022 22:15:22 +0100 Subject: [PATCH] swtpm is in Debian now :) --- README.md | 4 ++-- src/fd.cpp | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 45992c9..dddf9b4 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ See the [repository README](//debian.nabijaczleweli.xyz/README) for more informa ### Testing #### TPM2 -Build [`swtpm`](//github.com/stefanberger/swtpm), then prepare and run it: +Install [`swtpm`](//github.com/stefanberger/swtpm), then prepare and run it: ```sh swtpm_setup --tpmstate tpm2-state --tpm2 --createek --display --logfile /dev/tty --overwrite swtpm socket --server type=tcp,port=2321 --ctrl type=tcp,port=2322 --tpm2 --tpmstate dir=tpm2-state --flags not-need-init --log level=10 @@ -86,7 +86,7 @@ ln -s /usr/lib/i386-linux-gnu/libtss2-tcti-{swtpm,default}.so ``` #### TPM1.x -Build [`swtpm`](//github.com/stefanberger/swtpm), then prepare and run it and +Install [`swtpm`](//github.com/stefanberger/swtpm), then prepare and run it and ([hopefully](//github.com/stefanberger/swtpm/issues/5#issuecomment-210607890)) [TrouSerS](//sourceforge.net/projects/trousers), as `root`/`tpm`: ```sh swtpm_setup --tpmstate tpm1x-state --createek --display --logfile /dev/tty --overwrite diff --git a/src/fd.cpp b/src/fd.cpp index 9af018a..b6c04c5 100644 --- a/src/fd.cpp +++ b/src/fd.cpp @@ -158,8 +158,8 @@ static int get_key_material_raw(const char * whom, bool again, bool newkey, uint caught_interrupt = 0; act.sa_handler = [](auto sig) { - caught_interrupt = sig; - fputs("^C\n", stderr); + caught_interrupt = sig; + fputs("^C\n", stderr); }; sigaction(SIGINT, &act, &osigint); @@ -197,7 +197,9 @@ 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) @@ -256,6 +258,7 @@ 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) @@ -269,6 +272,7 @@ int read_new_passphrase(const char * whom, uint8_t *& buf, size_t & len_out, siz 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;