diff options
author | Leah Neukirchen <leah@vuxu.org> | 2018-01-03 18:18:49 +0100 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2018-01-03 18:18:49 +0100 |
commit | 08527a903562d5b0881e23ec286bdba56ecd1fa0 (patch) | |
tree | 9330292b6b484d715a2eb735464bc9b358321bfc | |
parent | d60ebea1fac988fbe7fe9b9d059f37e46cbbd018 (diff) | |
download | rdd-08527a903562d5b0881e23ec286bdba56ecd1fa0.tar.gz rdd-08527a903562d5b0881e23ec286bdba56ecd1fa0.tar.xz rdd-08527a903562d5b0881e23ec286bdba56ecd1fa0.zip |
reformat
-rw-r--r-- | rdd.c | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/rdd.c b/rdd.c index 321ad89..d9281c1 100644 --- a/rdd.c +++ b/rdd.c @@ -7,50 +7,50 @@ #include "sosemanuk.h" -#define fail(i,s) write(2, s, (sizeof s)-1), exit(i); +#define fail(i, s) write(2, s, (sizeof s)-1), exit(i); int main(int argc, char *argv[]) { - unsigned char key[32], iv[16], buf[120*512]; - sosemanuk_key_context kc; - sosemanuk_run_context rc; - - int fd, c, i, v=0, r=4; - char *src = "/dev/urandom"; - - while ((c = getopt(argc, argv, "i:r:v")) != -1) - switch(c) { - case 'i': src = optarg; break; - case 'r': r = atoi(optarg); break; - case 'v': v = 1; break; - default: - usage: - fail(1, "Usage: rdd [-i RANDOMSOURCE] [-r REKEYMB] [-v]\n"); - } - - if (argc > optind) - goto usage; - - if ((fd = open(src, O_RDONLY)) < 0) - fail(2, "failed to open random source\n"); - - if (read(fd, key, sizeof key) != sizeof key) - fail(3, "failed to read key from random source\n"); - sosemanuk_schedule(&kc, key, sizeof key); - - while (1) { - if (read(fd, iv, sizeof iv) != sizeof iv) - fail(3, "failed to read iv from random source\n"); - sosemanuk_init(&rc, &kc, iv, sizeof iv); - if (v) - write(2, ".", 1); - - for (i = 0; r<0 || i<r*1024*1024; i+=sizeof buf) { - sosemanuk_prng(&rc, buf, sizeof buf); - while (write(1, buf, sizeof buf) != sizeof buf) - if (errno && errno != EINTR) - fail(4, "write error\n"); - } - } + unsigned char key[32], iv[16], buf[120*512]; + sosemanuk_key_context kc; + sosemanuk_run_context rc; + + int fd, c, i, v = 0, r = 4; + char *src = "/dev/urandom"; + + while ((c = getopt(argc, argv, "i:r:v")) != -1) + switch (c) { + case 'i': src = optarg; break; + case 'r': r = atoi(optarg); break; + case 'v': v = 1; break; + default: +usage: + fail(1, "Usage: rdd [-i RANDOMSOURCE] [-r REKEYMB] [-v]\n"); + } + + if (argc > optind) + goto usage; + + if ((fd = open(src, O_RDONLY)) < 0) + fail(2, "failed to open random source\n"); + + if (read(fd, key, sizeof key) != sizeof key) + fail(3, "failed to read key from random source\n"); + sosemanuk_schedule(&kc, key, sizeof key); + + while (1) { + if (read(fd, iv, sizeof iv) != sizeof iv) + fail(3, "failed to read iv from random source\n"); + sosemanuk_init(&rc, &kc, iv, sizeof iv); + if (v) + write(2, ".", 1); + + for (i = 0; r < 0 || i < r*1024*1024; i += sizeof buf) { + sosemanuk_prng(&rc, buf, sizeof buf); + while (write(1, buf, sizeof buf) != sizeof buf) + if (errno && errno != EINTR) + fail(4, "write error\n"); + } + } } |