File: dqcache-makekey.c

package info (click to toggle)
dq 20230101-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,020 kB
  • sloc: ansic: 8,269; makefile: 363; sh: 176; python: 82
file content (27 lines) | stat: -rw-r--r-- 542 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
20160325
Jan Mojzis
Public domain.
*/

#include <unistd.h>
#include "randombytes.h"
#include "writeall.h"

static unsigned char sk[32];
static unsigned char out[65];

int main(int argc, char **argv) {

    long long i;

    randombytes(sk, sizeof sk);
    for (i = 0; i < 32; ++i) {
        out[2 * i + 0] = "0123456789abcdef"[15 & (int) (sk[i] >> 4)]; 
        out[2 * i + 1] = "0123456789abcdef"[15 & (int) (sk[i] >> 0)];
    }
    out[2 * i] = '\n';
    if (writeall(1, out, sizeof out) == -1) _exit(111);
    fsync(1);
    _exit(0);
}