From 72f5d00a532db2b78eb4c2835e58881546db86ff Mon Sep 17 00:00:00 2001 From: frankmorgner Date: Wed, 25 Jan 2012 09:49:50 +0000 Subject: [PATCH] better debug output git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@695 96b47cad-a561-4643-ad3b-153ac7d7599c --- .../vpicc/virtualsmartcard/VirtualSmartcard.py | 9 +++++---- .../src/vpicc/virtualsmartcard/cards/nPA.py | 18 ++++-------------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/virtualsmartcard/src/vpicc/virtualsmartcard/VirtualSmartcard.py b/virtualsmartcard/src/vpicc/virtualsmartcard/VirtualSmartcard.py index 0d58c72..d83ae18 100644 --- a/virtualsmartcard/src/vpicc/virtualsmartcard/VirtualSmartcard.py +++ b/virtualsmartcard/src/vpicc/virtualsmartcard/VirtualSmartcard.py @@ -274,6 +274,8 @@ class Iso7816OS(SmartcardOS): except ValueError as e: logging.warning(str(e)) return self.formatResult(False, 0, "", SW["ERR_INCORRECTPARAMETERS"], False) + + logging.info("Parsed APDU:\n%s", str(c)) #Handle Class Byte #{{{ @@ -325,6 +327,7 @@ class Iso7816OS(SmartcardOS): try: if SM_STATUS == "Standard SM": c = self.SAM.parse_SM_CAPDU(c, header_authentication) + logging.info("Decrypted APDU:\n%s", str(c)) elif SM_STATUS == "Proprietary SM": raise SwError("ERR_SECMESSNOTSUPPORTED") sw, result = self.ins2handler.get(c.ins, notImplemented)(c.p1, c.p2, c.data) @@ -661,11 +664,9 @@ class VirtualICC(object): logging.warning("Expected %u bytes, but received only %u", size, len(msg)) - logging.info("APDU (%d Bytes):\n%s", len(msg), - hexdump(msg, short=True)) answer = self.os.execute(msg) - logging.info("RESP (%d Bytes):\n%s\n", len(answer), - hexdump(answer, short=True)) + logging.info("Response APDU (%d Bytes):\n%s\n", len(answer), + hexdump(answer)) self.__sendToVPICC(answer) def stop(self): diff --git a/virtualsmartcard/src/vpicc/virtualsmartcard/cards/nPA.py b/virtualsmartcard/src/vpicc/virtualsmartcard/cards/nPA.py index cdf78d1..155b3fe 100644 --- a/virtualsmartcard/src/vpicc/virtualsmartcard/cards/nPA.py +++ b/virtualsmartcard/src/vpicc/virtualsmartcard/cards/nPA.py @@ -128,7 +128,6 @@ class nPA_SE(Security_Environment): if (p1, p2) != (0x00, 0x00): raise SwError(SW["ERR_INCORRECTPARAMETERS"]) - print "performing PACE step", self.eac_step + 1 if self.eac_step == 0 and self.at.algorithm == "PACE": return self.__eac_pace_step1(data) elif self.eac_step == 1 and self.at.algorithm == "PACE": @@ -258,6 +257,8 @@ class nPA_SE(Security_Environment): pace.print_ossl_err() raise SwError(SW["WARN_NOINFO63"]) + print "Established PACE channel" + if self.at.keyref_is_can(): if (self.sam.counter == 1): self.sam.active = True @@ -330,25 +331,14 @@ class nPA_SE(Security_Environment): else: auxiliary_data = None - #print "at.eph_pub_key" - #print hexdump(self.at.eph_pub_key) - #print "my_pace_eph_pubkey" - #print hexdump(pace.buf2string(self.my_pace_eph_pubkey)) - #print "data" - #print hexdump(data) - #if self.auxiliary_data: - #print "auxiliary_data" - #print hexdump(self.auxiliary_data) - #else: - #print "auxiliary_data" - #print "None" - if 1 != pace.TA_STEP6_verify(self.eac_ctx, pace.get_buf(self.at.eph_pub_key), id_picc, auxiliary_data, pace.get_buf(data)): pace.print_ossl_err() raise SwError(SW["ERR_CONDITIONNOTSATISFIED"]) + print "Terminal's signature verified" + self.eac_step += 1 return 0x9000, ""