mirror of
https://github.com/cathugger/mkp224o.git
synced 2025-12-05 21:27:13 -06:00
Add checkpointing support for passphrases
This commit is contained in:
@@ -36,18 +36,39 @@ void *worker_batch_pass(void *task)
|
||||
|
||||
sname = makesname();
|
||||
|
||||
// load checkpoint
|
||||
pthread_mutex_lock(&determseed_mutex);
|
||||
for (int i = 0; i < SEED_LEN; i++)
|
||||
determseed[i] += checkpoint[i];
|
||||
pthread_mutex_unlock(&determseed_mutex);
|
||||
|
||||
initseed:
|
||||
#ifdef STATISTICS
|
||||
++st->numrestart.v;
|
||||
#endif
|
||||
|
||||
pthread_mutex_lock(&determseed_mutex);
|
||||
for (int i = 0; i < SEED_LEN; i++)
|
||||
for (int i = 0; i < SEED_LEN; i++) {
|
||||
++checkpoint[i];
|
||||
if (++determseed[i])
|
||||
break;
|
||||
}
|
||||
memcpy(seed, determseed, SEED_LEN);
|
||||
pthread_mutex_unlock(&determseed_mutex);
|
||||
|
||||
if (checkpointfile) {
|
||||
FILE *checkout = fopen(checkpointfile, "w");
|
||||
if (!checkout) {
|
||||
fprintf(stderr,"cannot open checkpoint file for writing\n");
|
||||
exit(1);
|
||||
}
|
||||
if(fwrite(checkpoint, 1, SEED_LEN, checkout) != SEED_LEN) {
|
||||
fprintf(stderr,"cannot write to checkpoint file\n");
|
||||
exit(1);
|
||||
}
|
||||
fclose(checkout);
|
||||
}
|
||||
|
||||
ed25519_seckey_expand(sk,seed);
|
||||
|
||||
ge_scalarmult_base(&ge_public,sk);
|
||||
|
||||
Reference in New Issue
Block a user