2
0
Fork 0
mirror of https://git.sr.ht/~sircmpwn/mkproof synced 2024-05-23 17:16:11 +02:00
mkproof/src/mkchallenge.c

37 lines
641 B
C
Raw Normal View History

2020-11-25 18:05:19 +01:00
#include <assert.h>
2020-11-25 17:15:59 +01:00
#include <stdio.h>
2020-11-25 18:05:19 +01:00
#include <stdlib.h>
#include <unistd.h>
#include "random.h"
#include "util.h"
#define ALGORITHM "argon2id"
2020-11-25 18:42:46 +01:00
#define ITERATIONS 10
2020-11-25 18:05:19 +01:00
#define MEMORY 12
2020-11-25 18:42:46 +01:00
#define DIGITS 5
2020-11-25 18:05:19 +01:00
static void
usage(char *argv_0)
{
exit(1);
}
2020-11-25 17:15:59 +01:00
int
main(int argc, char *argv[])
{
2020-11-25 18:42:46 +01:00
if (argc != 1) {
fprintf(stderr, "Usage: %s\n", argv[0]);
2020-11-25 18:05:19 +01:00
usage(argv[0]);
}
unsigned char seed[16];
ssize_t n = get_random_bytes(seed, sizeof(seed));
assert(n == sizeof(seed));
char seedhex[33];
enchex(seed, sizeof(seed), seedhex, sizeof(seedhex));
printf("%s:%d:%d:%d:%s\n", ALGORITHM,
2020-11-25 18:42:46 +01:00
ITERATIONS, MEMORY, DIGITS, seedhex);
2020-11-25 17:15:59 +01:00
return 0;
}