2
0
Fork 0
mirror of https://git.sr.ht/~sircmpwn/mkproof synced 2024-06-03 07:26:10 +02:00

ensure -m or -k is only used once

This commit is contained in:
goblin 2017-06-01 19:52:07 +02:00
parent 7bab9ed820
commit c9f9c951de

View File

@ -37,8 +37,9 @@
#define UNUSED_PARAMETER(x) (void)(x)
static void usage(const char *cmd) {
printf("Usage: %s [-h] salt [-i|-d|-id] [-t iterations] [-m log2(memory in KiB)] "
"[-k memory in KiB] [-p parallelism] [-l hash length] [-e|-r] [-v (10|13)]\n",
printf("Usage: %s [-h] salt [-i|-d|-id] [-t iterations] "
"[-m log2(memory in KiB) | -k memory in KiB] [-p parallelism] "
"[-l hash length] [-e|-r] [-v (10|13)]\n",
cmd);
printf("\tPassword is read from stdin\n");
printf("Parameters:\n");
@ -176,6 +177,7 @@ int main(int argc, char *argv[]) {
uint32_t threads = THREADS_DEF;
argon2_type type = Argon2_i; /* Argon2i is the default type */
int types_specified = 0;
int m_cost_specified = 0;
int encoded_only = 0;
int raw_only = 0;
uint32_t version = ARGON2_VERSION_NUMBER;
@ -215,6 +217,10 @@ int main(int argc, char *argv[]) {
usage(argv[0]);
return 1;
} else if (!strcmp(a, "-m")) {
if (m_cost_specified) {
fatal("-m or -k can only be used once");
}
m_cost_specified = 1;
if (i < argc - 1) {
i++;
input = strtoul(argv[i], NULL, 10);
@ -231,6 +237,10 @@ int main(int argc, char *argv[]) {
fatal("missing -m argument");
}
} else if (!strcmp(a, "-k")) {
if (m_cost_specified) {
fatal("-m or -k can only be used once");
}
m_cost_specified = 1;
if (i < argc - 1) {
i++;
input = strtoul(argv[i], NULL, 10);