diff --git a/editor.c b/editor.c index 2419e75..81a47eb 100644 --- a/editor.c +++ b/editor.c @@ -439,6 +439,14 @@ static enum cmd_returncode_t cmd_rawdump(struct editor_context_t *ctx, const cha for (unsigned int i = 0; i < ctx->keydb->host_count; i++) { struct host_entry_t *host = &ctx->keydb->hosts[i]; fprintf(stderr, "Host %d:\n", i); + { + char host_uuid[ASCII_UUID_BUFSIZE]; + sprintf_uuid(host_uuid, host->host_uuid); + + char hex_psk[(PSK_SIZE_BYTES * 2) + 1]; + sprintf_hex(hex_psk, host->tls_psk, PSK_SIZE_BYTES); + fprintf(stderr, "openssl s_client -connect 127.0.0.1:23170 -psk %s -psk_identity %s -curves X448:X25519 -ciphersuites TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384 -tls1_3\n", hex_psk, host_uuid); + } dump_hexline(stderr, " host_uuid ", host->host_uuid, sizeof(host->host_uuid), false); dump_hexline(stderr, " host_name ", host->host_name, sizeof(host->host_name), true); dump_hexline(stderr, " tls_psk ", host->tls_psk, sizeof(host->tls_psk), false); diff --git a/util.c b/util.c index bf1619c..8d56d06 100644 --- a/util.c +++ b/util.c @@ -54,6 +54,12 @@ void dump_hex_long(FILE *f, const void *vdata, unsigned int length) { } } +void sprintf_hex(char *dest, const uint8_t *data, unsigned int length) { + for (unsigned int i = 0; i < length; i++) { + sprintf(dest + (2 * i), "%02x", data[i]); + } +} + void dump_hex(FILE *f, const void *vdata, unsigned int length, bool use_ascii) { const uint8_t *data = (const uint8_t*)vdata; for (unsigned int i = 0; i < length; i++) { diff --git a/util.h b/util.h index f2f7c43..c7564f8 100644 --- a/util.h +++ b/util.h @@ -33,6 +33,7 @@ /*************** AUTO GENERATED SECTION FOLLOWS ***************/ bool query_passphrase(const char *prompt, char *passphrase, unsigned int passphrase_maxsize); void dump_hex_long(FILE *f, const void *vdata, unsigned int length); +void sprintf_hex(char *dest, const uint8_t *data, unsigned int length); void dump_hex(FILE *f, const void *vdata, unsigned int length, bool use_ascii); void dump_hexline(FILE *f, const char *prefix, const void *vdata, unsigned int length, bool use_ascii); bool is_hex(const char *str, int length);