Skip to content

Commit

Permalink
fix error condition for yk_challenge_response()
Browse files Browse the repository at this point in the history
  • Loading branch information
eworm-de committed May 3, 2016
1 parent 43e9a77 commit 8c5352f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
14 changes: 8 additions & 6 deletions bin/ykfde.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions udev/ykfde.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8c5352f

Please sign in to comment.