mirror of
https://github.com/cathugger/mkp224o.git
synced 2025-05-04 20:30:34 +00:00
tweak passphrase code
This commit is contained in:
parent
01b733a704
commit
f0587c98c3
1 changed files with 12 additions and 11 deletions
23
main.c
23
main.c
|
@ -926,26 +926,27 @@ int main(int argc,char **argv)
|
|||
#ifdef PASSPHRASE
|
||||
} else if (*arg == 'p') {
|
||||
if (argc--) {
|
||||
const char *phrase = *argv++;
|
||||
|
||||
deterministic = 1;
|
||||
static unsigned char salt[crypto_pwhash_SALTBYTES] = {0};
|
||||
const char *phrase = *argv;
|
||||
if (!strcmp(phrase, "@")) {
|
||||
if (!strcmp(phrase,"@")) {
|
||||
phrase = getenv("PASSPHRASE");
|
||||
if (phrase == NULL) {
|
||||
fprintf(stderr, "store passphrase in PASSPHRASE environment variable\n");
|
||||
fprintf(stderr,"store passphrase in PASSPHRASE environment variable\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
deterministic = 1;
|
||||
fprintf(stderr, "expanding passphrase..."); fflush(stderr);
|
||||
if (crypto_pwhash(determseed, sizeof(determseed),
|
||||
phrase, strlen(phrase), salt,
|
||||
PWHASH_OPSLIMIT, PWHASH_MEMLIMIT, PWHASH_ALG)) {
|
||||
|
||||
fprintf(stderr, " out of memory!\n");
|
||||
fprintf(stderr,"expanding passphrase...");
|
||||
if (crypto_pwhash(determseed,sizeof(determseed),
|
||||
phrase,strlen(phrase),salt,
|
||||
PWHASH_OPSLIMIT,PWHASH_MEMLIMIT,PWHASH_ALG) != 0)
|
||||
{
|
||||
fprintf(stderr," out of memory!\n");
|
||||
exit(1);
|
||||
}
|
||||
fprintf(stderr, " done.\n");
|
||||
argv++;
|
||||
fprintf(stderr," done.\n");
|
||||
} else
|
||||
e_additional();
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue