mirror of https://github.com/ericonr/get-otp.git
Compare commits
2 Commits
afd45ea983
...
599b7f431e
Author | SHA1 | Date |
---|---|---|
Érico Nogueira | 599b7f431e | |
Érico Nogueira | 9592de802c |
18
cbc-file.c
18
cbc-file.c
|
@ -50,6 +50,8 @@ static void usage(void)
|
|||
|
||||
static int read_password(uint8_t *key, const uint8_t *salt)
|
||||
{
|
||||
int rv = -1;
|
||||
|
||||
fprintf(stderr, "input password (up to %d): ", KEY_LENGTH);
|
||||
|
||||
struct termios old, t;
|
||||
|
@ -61,17 +63,21 @@ static int read_password(uint8_t *key, const uint8_t *salt)
|
|||
|
||||
char pass[PASS_LENGTH];
|
||||
if (fgets(pass, PASS_LENGTH, stdin) == NULL) {
|
||||
return -1;
|
||||
// echo should always be turned off at exit
|
||||
goto end;
|
||||
}
|
||||
rv = 0;
|
||||
|
||||
argon2id_hash_raw(
|
||||
TIME_COST, MEM_COST, PARALLEL,
|
||||
pass, strlen(pass), salt, SALT_LENGTH,
|
||||
key, KEY_LENGTH);
|
||||
|
||||
end:
|
||||
// restore previous attributes
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &old);
|
||||
|
||||
argon2id_hash_raw(TIME_COST, MEM_COST, PARALLEL,
|
||||
pass, strlen(pass), salt, SALT_LENGTH,
|
||||
key, KEY_LENGTH);
|
||||
|
||||
return 0;
|
||||
return rv;
|
||||
}
|
||||
|
||||
static off_t file_size(int fd)
|
||||
|
|
12
get-otp.in
12
get-otp.in
|
@ -3,9 +3,19 @@ file="${OTP_ACCOUNTS:-$HOME/.local/share/otp_accounts}"
|
|||
json="$(@PREFIX@/bin/cbc-file unlock "$file")"
|
||||
[ -z "$json" ] && exit 1
|
||||
|
||||
finder=
|
||||
if command -v ef >/dev/null; then
|
||||
finder="ef -c -1"
|
||||
elif command -v fzf >/dev/null; then
|
||||
finder="fzf --cycle -1"
|
||||
else
|
||||
echo "couldn't find finder" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
label="$(printf %s "$json" |
|
||||
jq '.[].label' 2>/dev/null |
|
||||
fzf --cycle -1 ${1:+--query "$1"}
|
||||
$finder ${1:+-q "$1"}
|
||||
)"
|
||||
[ -z "$label" ] && exit 1
|
||||
|
||||
|
|
Loading…
Reference in New Issue