mirror of
https://github.com/ckolivas/lrzip.git
synced 2025-12-06 07:12:00 +01:00
add password callback hook
This commit is contained in:
parent
cbff8faef7
commit
08d2294e5e
10
lrzip.c
10
lrzip.c
|
|
@ -538,6 +538,10 @@ static void get_hash(rzip_control *control, int make_hash)
|
|||
mlock(control->salt_pass, PASS_LEN);
|
||||
mlock(control->hash, HASH_LEN);
|
||||
|
||||
if (control->pass_cb) {
|
||||
control->pass_cb(control->pass_data, passphrase, PASS_LEN);
|
||||
if (!passphrase[0]) fatal(control, "Supplied password was null!");
|
||||
} else {
|
||||
/* Disable stdin echo to screen */
|
||||
tcgetattr(fileno(stdin), &termios_p);
|
||||
termios_p.c_lflag &= ~ECHO;
|
||||
|
|
@ -558,14 +562,14 @@ retry_pass:
|
|||
termios_p.c_lflag |= ECHO;
|
||||
tcsetattr(fileno(stdin), 0, &termios_p);
|
||||
memset(testphrase, 0, PASS_LEN);
|
||||
munlock(testphrase, PASS_LEN);
|
||||
free(testphrase);
|
||||
|
||||
}
|
||||
memcpy(control->salt_pass, control->salt, SALT_LEN);
|
||||
memcpy(control->salt_pass + SALT_LEN, passphrase, PASS_LEN - SALT_LEN);
|
||||
lrz_stretch(control);
|
||||
memset(passphrase, 0, PASS_LEN);
|
||||
munlock(passphrase, PASS_LEN);
|
||||
munlock(testphrase, PASS_LEN);
|
||||
free(testphrase);
|
||||
free(passphrase);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -311,6 +311,8 @@ struct rzip_control {
|
|||
int fd_hist;
|
||||
i64 encloops;
|
||||
i64 secs;
|
||||
void (*pass_cb)(void *, char *, size_t); /* callback to get password in lib */
|
||||
void *pass_data;
|
||||
uchar salt[SALT_LEN];
|
||||
uchar *salt_pass;
|
||||
int salt_pass_len;
|
||||
|
|
|
|||
Loading…
Reference in a new issue