[pkg-opensc-commit] [opensc] 250/295: Disable the secure channel at logout (#1048)

Eric Dorland eric at moszumanska.debian.org
Sat Jun 24 21:11:37 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 d9d247e6cd826ea3f08ad29f8d29e6ca06c78f21
Author: rickyepoderi <rickyepoderi at yahoo.es>
Date:   Sat May 13 16:15:08 2017 +0200

    Disable the secure channel at logout (#1048)
    
    Fixes https://github.com/OpenSC/OpenSC/issues/1036
---
 src/libopensc/card-dnie.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/libopensc/card-dnie.c b/src/libopensc/card-dnie.c
index 284528a..6260e81 100644
--- a/src/libopensc/card-dnie.c
+++ b/src/libopensc/card-dnie.c
@@ -1406,14 +1406,26 @@ static int dnie_get_challenge(struct sc_card *card, u8 * rnd, size_t len)
 static int dnie_logout(struct sc_card *card)
 {
 	int result = SC_SUCCESS;
+	sc_file_t *file = NULL;
 
 	if ((card == NULL) || (card->ctx == NULL))
 		return SC_ERROR_INVALID_ARGUMENTS;
+
 	LOG_FUNC_CALLED(card->ctx);
-	/* disable and free any sm channel related data */
-	result =
-	    cwa_create_secure_channel(card, GET_DNIE_PRIV_DATA(card)->cwa_provider, CWA_SM_OFF);
-	/* TODO: _logout() see comments.txt on what to do here */
+	if (card->sm_ctx.sm_mode != SM_MODE_NONE) {
+		/* mark the channel as closed */
+		result = cwa_create_secure_channel(card, 
+			GET_DNIE_PRIV_DATA(card)->cwa_provider, CWA_SM_OFF);
+		LOG_TEST_RET(card->ctx, result, "Cannot close the secure channel");
+		/* request the Master File to provoke an SM error and close the channel */
+		result = dnie_compose_and_send_apdu(card, (const u8 *) DNIE_MF_NAME, 
+			sizeof(DNIE_MF_NAME) - 1, 4, &file);
+		if (result == SC_ERROR_SM)
+			result = SC_SUCCESS;
+	}
+
+	if (file != NULL)
+		sc_file_free(file);
 	LOG_FUNC_RETURN(card->ctx, result);
 }
 

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