[pkg-opensc-commit] [opensc] 06/23: [cac] Correctly select APDU CASE to unbreak get_challenge

Eric Dorland eric at moszumanska.debian.org
Sun Jul 23 18:23:08 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 7e28c1b4e0f739d37c19773e49fb4ab5db4ae065
Author: Jakub Jelen <jjelen at redhat.com>
Date:   Mon Jun 26 16:04:48 2017 +0200

    [cac] Correctly select APDU CASE to unbreak get_challenge
---
 src/libopensc/card-cac.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/libopensc/card-cac.c b/src/libopensc/card-cac.c
index e1748bf..36f911e 100644
--- a/src/libopensc/card-cac.c
+++ b/src/libopensc/card-cac.c
@@ -331,6 +331,7 @@ static int cac_apdu_io(sc_card_t *card, int ins, int p1, int p2,
 	u8 rbufinitbuf[CAC_MAX_SIZE];
 	u8 *rbuf;
 	size_t rbuflen;
+	unsigned int apdu_case = SC_APDU_CASE_1;
 
 
 	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
@@ -349,9 +350,16 @@ static int cac_apdu_io(sc_card_t *card, int ins, int p1, int p2,
 		rbuflen = *recvbuflen;
 	}
 
-	sc_format_apdu(card, &apdu,
-			recvbuf ? SC_APDU_CASE_4_SHORT: SC_APDU_CASE_3_SHORT,
-			ins, p1, p2);
+	if (recvbuf) {
+		if (sendbuf)
+			apdu_case = SC_APDU_CASE_4_SHORT;
+		else
+			apdu_case = SC_APDU_CASE_2_SHORT;
+	} else if (sendbuf)
+		apdu_case = SC_APDU_CASE_3_SHORT;
+
+
+	sc_format_apdu(card, &apdu, apdu_case, ins, p1, p2);
 
 	apdu.lc = sendbuflen;
 	apdu.datalen = sendbuflen;

-- 
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