summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2016-05-03 23:16:17 +0200
committerGravatar Christian Hesse <mail@eworm.de>2016-05-03 23:16:17 +0200
commit8c5352f0175bf063056b54118cb93edb734d15a0 (patch)
tree75e159eccc1dde99aac22eced00e1edf3aa84eb5
parent43e9a771c9d669f93313aefb1da750fba4363cbe (diff)
downloadmkinitcpio-ykfde-8c5352f0175bf063056b54118cb93edb734d15a0.tar.gz
mkinitcpio-ykfde-8c5352f0175bf063056b54118cb93edb734d15a0.tar.zst
fix error condition for yk_challenge_response()
-rw-r--r--bin/ykfde.c14
-rw-r--r--udev/ykfde.c7
2 files changed, 12 insertions, 9 deletions
diff --git a/bin/ykfde.c b/bin/ykfde.c
index 1e70cbf..1277e2c 100644
--- a/bin/ykfde.c
+++ b/bin/ykfde.c
@@ -238,10 +238,11 @@ int main(int argc, char **argv) {
memcpy(challenge_new, tmp, plen < MAX2FLEN ? plen : MAX2FLEN);
/* do challenge/response and encode to hex */
- if ((rc = yk_challenge_response(yk, yk_slot, true,
- CHALLENGELEN, (unsigned char *) challenge_new,
- RESPONSELEN, (unsigned char *) response_new)) < 0) {
+ if (yk_challenge_response(yk, yk_slot, true,
+ CHALLENGELEN, (unsigned char *) challenge_new,
+ RESPONSELEN, (unsigned char *) response_new) == 0) {
perror("yk_challenge_response() failed");
+ rc = EXIT_FAILURE;
goto out50;
}
yubikey_hex_encode((char *) passphrase_new, (char *) response_new, SHA1_DIGEST_SIZE);
@@ -287,10 +288,11 @@ int main(int argc, char **argv) {
memcpy(challenge_old, payload, plen < MAX2FLEN ? plen : MAX2FLEN);
/* do challenge/response and encode to hex */
- if ((rc = yk_challenge_response(yk, yk_slot, true,
- CHALLENGELEN, (unsigned char *) challenge_old,
- RESPONSELEN, (unsigned char *) response_old)) < 0) {
+ if (yk_challenge_response(yk, yk_slot, true,
+ CHALLENGELEN, (unsigned char *) challenge_old,
+ RESPONSELEN, (unsigned char *) response_old) == 0) {
perror("yk_challenge_response() failed");
+ rc = EXIT_FAILURE;
goto out60;
}
yubikey_hex_encode((char *) passphrase_old, (char *) response_old, SHA1_DIGEST_SIZE);
diff --git a/udev/ykfde.c b/udev/ykfde.c
index 5d72d81..43b25e4 100644
--- a/udev/ykfde.c
+++ b/udev/ykfde.c
@@ -114,10 +114,11 @@ static int try_answer(YK_KEY * yk, uint8_t slot, const char * ask_file, char * c
}
/* do challenge/response and encode to hex */
- if ((rc = yk_challenge_response(yk, slot, true,
- CHALLENGELEN, (unsigned char *) challenge,
- RESPONSELEN, (unsigned char *) response)) < 0) {
+ if (yk_challenge_response(yk, slot, true,
+ CHALLENGELEN, (unsigned char *) challenge,
+ RESPONSELEN, (unsigned char *) response) == 0) {
perror("yk_challenge_response() failed");
+ rc = EXIT_FAILURE;
goto out1;
}
yubikey_hex_encode((char *) passphrase, (char *) response, SHA1_DIGEST_SIZE);