Add checkpointing support for passphrases

This commit is contained in:
scribblemaniac 2021-10-15 22:53:53 -06:00
parent ff3873965f
commit 2a4afad91a
No known key found for this signature in database
GPG key ID: 7C7B792A6AD57A97
5 changed files with 67 additions and 2 deletions

19
main.c
View file

@ -112,6 +112,7 @@ static void printhelp(FILE *out,const char *progname)
#ifdef PASSPHRASE
"\t-p passphrase - use passphrase to initialize the random seed with\n"
"\t-P - same as -p, but takes passphrase from PASSPHRASE environment variable\n"
"\t-c filename - load/save checkpoint of progress to specified file (requires passphrase)\n"
#endif
,progname,progname);
fflush(out);
@ -393,6 +394,12 @@ int main(int argc,char **argv)
setpassphrase(pass);
deterministic = 1;
}
else if (*arg == 'c') {
if (argc--)
checkpointfile = *argv++;
else
e_additional();
}
#endif // PASSPHRASE
else {
fprintf(stderr,"unrecognised argument: -%c\n",*arg);
@ -465,6 +472,18 @@ int main(int argc,char **argv)
goto done;
}
if (checkpointfile) {
// Read current checkpoint position if file exists
FILE *checkout = fopen(checkpointfile, "r");
if (checkout) {
if(fread(checkpoint, 1, SEED_LEN, checkout) != SEED_LEN) {
fprintf(stderr,"failed to read checkpoint file\n");
exit(1);
}
fclose(checkout);
}
}
filters_prepare();
filters_print();