Skip to content

Commit

Permalink
Use a new random secret key without keyfile
Browse files Browse the repository at this point in the history
  • Loading branch information
angt committed Dec 15, 2015
1 parent 893de45 commit ddae22a
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down

1 comment on commit ddae22a

@jedisct1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you had to do that?

Please sign in to comment.