[pkg-opensc-commit] [opensc] 60/295: piv: add a piv_card_reader_lock_obtained function

Eric Dorland eric at moszumanska.debian.org
Sat Jun 24 21:11:16 UTC 2017


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository opensc.

commit bb2d863e4f05f5871a9255e8a450a62cc065db76
Author: Doug Engert <deengert at gmail.com>
Date:   Sat Jul 30 08:52:36 2016 -0500

    piv: add a piv_card_reader_lock_obtained function
    
    When sc_lock obtains a reader lock  this function is called
    If the card was reset the PIV AID is seletcted and logged_in is reset.
    This is need for some PIV cards where the default AID is not the PIV AID
    and some other process has reset the card.
    
    closes #842
---
 src/libopensc/card-piv.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/libopensc/card-piv.c b/src/libopensc/card-piv.c
index e0b3c9c..e3ad4da 100644
--- a/src/libopensc/card-piv.c
+++ b/src/libopensc/card-piv.c
@@ -3301,6 +3301,26 @@ static int piv_logout(sc_card_t *card)
 }
 
 
+static int piv_card_reader_lock_obtained(sc_card_t *card, int was_reset)
+{
+	int r = 0;
+	u8 temp[2000];
+	size_t templen = sizeof(temp);
+	piv_private_data_t * priv = PIV_DATA(card); /* may be null */
+
+	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
+	if (was_reset > 0) {
+		if (priv)
+			priv->logged_in =  SC_PIN_STATE_UNKNOWN;
+
+		r = piv_select_aid(card, piv_aids[0].value, piv_aids[0].len_short, temp, &templen);
+	}
+
+	LOG_FUNC_RETURN(card->ctx, r);
+}
+
+
+
 static struct sc_card_driver * sc_get_driver(void)
 {
 	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
@@ -3322,6 +3342,7 @@ static struct sc_card_driver * sc_get_driver(void)
 	piv_ops.check_sw = piv_check_sw;
 	piv_ops.card_ctl = piv_card_ctl;
 	piv_ops.pin_cmd = piv_pin_cmd;
+	piv_ops.card_reader_lock_obtained = piv_card_reader_lock_obtained;
 
 	return &piv_drv;
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opensc/opensc.git



More information about the pkg-opensc-commit mailing list