From ddae22a3d91b0cb07c489903aa90f952a26de3da Mon Sep 17 00:00:00 2001 From: angt Date: Tue, 15 Dec 2015 09:07:44 +0100 Subject: [PATCH] Use a new random secret key without keyfile --- src/main.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main.c b/src/main.c index dcd91c5..1c24c08 100644 --- a/src/main.c +++ b/src/main.c @@ -554,10 +554,16 @@ static int gt_setup_secretkey (struct crypto_ctx *ctx, char *keyfile) { const size_t size = sizeof(ctx->skey); - byte_set(ctx->skey, 1, size); + if (!keyfile) { + char buf[2*size+1]; + + randombytes_buf(ctx->skey, size); + gt_tohex(buf, sizeof(buf), ctx->skey, size); + + gt_print("new secret key: %s\n", buf); - if (!keyfile) return 0; + } int fd; @@ -756,11 +762,6 @@ int main (int argc, char **argv) return 1; } - struct crypto_ctx ctx; - - if (gt_setup_secretkey(&ctx, keyfile)) - return 1; - struct addrinfo *ai = ai_create(host, port, listener); if (!ai) @@ -799,6 +800,11 @@ int main (int argc, char **argv) return 1; } + struct crypto_ctx ctx; + + if (gt_setup_secretkey(&ctx, keyfile)) + return 1; + if (option_is_set(opts, "daemon")) { switch (fork()) { case -1: