tweak passphrase code

This commit is contained in:
cathugger
2019-02-13 23:54:00 +00:00
parent 01b733a704
commit f0587c98c3

13
main.c
View File

@@ -926,8 +926,10 @@ int main(int argc,char **argv)
#ifdef PASSPHRASE #ifdef PASSPHRASE
} else if (*arg == 'p') { } else if (*arg == 'p') {
if (argc--) { if (argc--) {
const char *phrase = *argv++;
deterministic = 1;
static unsigned char salt[crypto_pwhash_SALTBYTES] = {0}; static unsigned char salt[crypto_pwhash_SALTBYTES] = {0};
const char *phrase = *argv;
if (!strcmp(phrase,"@")) { if (!strcmp(phrase,"@")) {
phrase = getenv("PASSPHRASE"); phrase = getenv("PASSPHRASE");
if (phrase == NULL) { if (phrase == NULL) {
@@ -935,17 +937,16 @@ int main(int argc,char **argv)
exit(1); exit(1);
} }
} }
deterministic = 1;
fprintf(stderr, "expanding passphrase..."); fflush(stderr); fprintf(stderr,"expanding passphrase...");
if (crypto_pwhash(determseed,sizeof(determseed), if (crypto_pwhash(determseed,sizeof(determseed),
phrase,strlen(phrase),salt, phrase,strlen(phrase),salt,
PWHASH_OPSLIMIT, PWHASH_MEMLIMIT, PWHASH_ALG)) { PWHASH_OPSLIMIT,PWHASH_MEMLIMIT,PWHASH_ALG) != 0)
{
fprintf(stderr," out of memory!\n"); fprintf(stderr," out of memory!\n");
exit(1); exit(1);
} }
fprintf(stderr," done.\n"); fprintf(stderr," done.\n");
argv++;
} else } else
e_additional(); e_additional();
#endif #endif