Skip to content

Commit

Permalink
PIV - Fix blanks and use returned value
Browse files Browse the repository at this point in the history
 On branch piv-improved-matching
 Changes to be committed:
	modified:   card-piv.c
  • Loading branch information
dengert committed Dec 12, 2018
1 parent 974ffd8 commit c319fa3
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/libopensc/card-piv.c
Original file line number Diff line number Diff line change
Expand Up @@ -2278,8 +2278,8 @@ static int piv_get_challenge(sc_card_t *card, u8 *rnd, size_t len)
/* NIST 800-73-3 says use 9B, previous verisons used 00 */
r = piv_general_io(card, 0x87, 0x00, 0x9B, sbuf, sizeof sbuf, &rbuf, &rbuf_len);
/*
* piv_get_challenge is called in a loop.
* some cards may allow 1 challenge expecting it to be part of
* piv_get_challenge is called in a loop.
* some cards may allow 1 challenge expecting it to be part of
* NIST 800-73-3 part 2 "Authentication of PIV Card Application Administrator"
* and return "6A 80" if last command was a get_challenge.
* Now that the card returned error, we can try one more time.
Expand Down Expand Up @@ -2738,9 +2738,7 @@ static int piv_process_discovery(sc_card_t *card)

/* CCC entries are simple tlv */
end = body + bodylen;

for(; (body < end); body += len) {

r = sc_simpletlv_read_tag((u8**)&body, end - body , &tag, &len);
if (r < 0)
goto err;
Expand Down Expand Up @@ -3188,8 +3186,8 @@ static int piv_match_card_continued(sc_card_t *card)
if (type == -1) {
/* use known ATRs */
i = _sc_match_atr(card, piv_atrs, &type);
if (type == -1)
type = SC_CARD_TYPE_PIV_II_GENERIC; /* may still be CAC with PIV Endpoint */
if (i < 0)
type = SC_CARD_TYPE_PIV_II_GENERIC; /* may still be CAC with PIV Endpoint */
}
}

Expand All @@ -3207,7 +3205,7 @@ static int piv_match_card_continued(sc_card_t *card)
card->drv_data = priv; /* will free if no match, or pass on to piv_init */
priv->selected_obj = -1;
priv->pin_preference = 0x80; /* 800-73-3 part 1, table 3 */
/* TODO Dual CAC/PIV are bases on 800-73-1 were priv->pin_preference = 0. need to check later */
/* TODO Dual CAC/PIV are bases on 800-73-1 where priv->pin_preference = 0. need to check later */
priv->logged_in = SC_PIN_STATE_UNKNOWN;
priv->tries_left = 10; /* will assume OK at start */
priv->pstate = PIV_STATE_MATCH;
Expand Down

0 comments on commit c319fa3

Please sign in to comment.