From a2e0b6901cb4eef7ad1d78bee0d70c577c61e0f5 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Sun, 25 Feb 2018 19:16:56 -0500 Subject: Rewrite everything --- setup.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'setup.c') diff --git a/setup.c b/setup.c index 633a1f4..92509e3 100644 --- a/setup.c +++ b/setup.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2018, Curtis McEnroe +/* Copyright (C) 2018 Causal Agent June * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -23,18 +23,18 @@ #include int main(int argc, char *argv[]) { - if (argc < 2) return EX_USAGE; + if (argc < 2) errx(EX_USAGE, "missing public id"); - uint32_t key[4]; + uint32_t id[4]; char public[7 + 32 + 1]; char private[8 + 32 + 1]; + arc4random_buf(id, sizeof(id)); snprintf(public, sizeof(public), "public/%s", argv[1]); - arc4random_buf(key, sizeof(key)); snprintf( private, sizeof(private), "private/%08x%08x%08x%08x", - key[0], key[1], key[2], key[3] + id[0], id[1], id[2], id[3] ); int fd = open(public, O_CREAT | O_EXCL, 0644); @@ -44,6 +44,6 @@ int main(int argc, char *argv[]) { int error = symlink(public, private); if (error) err(EX_CANTCREAT, "%s", private); - printf("%08x%08x%08x%08x\n", key[0], key[1], key[2], key[3]); + printf("%08x%08x%08x%08x\n", id[0], id[1], id[2], id[3]); return EX_OK; } -- cgit 1.4.1