From 6ad3f6070ca413021e5d39cde18c4c8fb41a83e7 Mon Sep 17 00:00:00 2001 From: Frank Morgner Date: Thu, 27 Feb 2014 01:13:15 +0100 Subject: [PATCH] return remaining tries of PIN verification in MSE:Set AT --- .../src/vpicc/virtualsmartcard/cards/nPA.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/virtualsmartcard/src/vpicc/virtualsmartcard/cards/nPA.py b/virtualsmartcard/src/vpicc/virtualsmartcard/cards/nPA.py index 31fef08..6763184 100644 --- a/virtualsmartcard/src/vpicc/virtualsmartcard/cards/nPA.py +++ b/virtualsmartcard/src/vpicc/virtualsmartcard/cards/nPA.py @@ -77,18 +77,6 @@ class nPA_AT_CRT(ControlReferenceTemplate): else: raise SwError(SW["ERR_REFNOTUSABLE"]) - structure = unpack(config) - - pin_ref_str = '%c'% self.PACE_PIN - for tlv in structure: - if [0x83, len(pin_ref_str), pin_ref_str] == tlv: - if self.sam.counter <= 0: - r = 0x63c0 - elif self.sam.counter == 1: - r = 0x63c1 - elif self.sam.counter == 2: - r = 0x63c2 - return r, "" class nPA_SE(Security_Environment): @@ -113,6 +101,13 @@ class nPA_SE(Security_Environment): sw, resp = Security_Environment._set_SE(self, p2, data) if self.at.algorithm == "PACE": + if self.at.keyref_is_pin(): + if self.sam.counter <= 0: + print "Must use PUK to unblock" + raise SwError(SW["WARN_NOINFO63"]) + if self.sam.counter == 1 and not self.sam.active: + print "Must use CAN to activate" + return 0x63c1, "" self.eac_step = 0 elif self.at.algorithm == "TA": if self.eac_step != 4: