fix test/
authorNIIBE Yutaka <gniibe@fsij.org>
Wed, 12 Oct 2016 06:32:51 +0000 (15:32 +0900)
committerNIIBE Yutaka <gniibe@fsij.org>
Wed, 12 Oct 2016 06:32:51 +0000 (15:32 +0900)
ChangeLog
test/features/steps.py
tests/openpgp_card.py
tool/gnuk_token.py

index c6ba640..3177963 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2016-10-12  Niibe Yutaka  <gniibe@fsij.org>
+
+       * test/features/steps.py (cmd_reset_retry_counter): Fix.
+       * tool/gnuk_token.py (gnuk_token.cmd_reset_retry_counter): Fix.
+       (gnuk_token.cmd_select_openpgp): Fix P2.
+
 2016-09-02  Niibe Yutaka  <gniibe@fsij.org>
 
        * src/configure (REVISION): Fix the detection of .git.
index dcd81e1..2e00ff4 100644 (file)
@@ -36,7 +36,7 @@ def cmd_put_data(tag_str,content_str_repr):
 @Given("cmd_reset_retry_counter with (.*) and \"(.*)\"")
 def cmd_reset_retry_counter(how_str, data):
     how = int(how_str)
-    scc.result = glc.token.cmd_reset_retry_counter(how, data)
+    scc.result = glc.token.cmd_reset_retry_counter(how, 0x81, data)
 
 @Given("a RSA key pair (.*)")
 def set_rsa_key(keyno_str):
index 84307df..e413293 100644 (file)
@@ -205,7 +205,6 @@ class OpenPGP_Card(object):
     def cmd_pso_longdata(self, p1, p2, data):
         if self.__reader.is_tpdu_reader():
             cmd_data = iso7816_compose(0x2a, p1, p2, data, le=256)
-            print(cmd_data)
             r = self.__reader.send_cmd(cmd_data)
             if len(r) < 2:
                 raise ValueError(r)
index a6280f5..c4ffac7 100644 (file)
@@ -289,13 +289,19 @@ class gnuk_token(object):
             count += 1
 
     def cmd_select_openpgp(self):
-        cmd_data = iso7816_compose(0xa4, 0x04, 0x0c, b"\xD2\x76\x00\x01\x24\x01")
-        sw = self.icc_send_cmd(cmd_data)
-        if len(sw) != 2:
-            raise ValueError(sw)
-        if not (sw[0] == 0x90 and sw[1] == 0x00):
+        cmd_data = iso7816_compose(0xa4, 0x04, 0x00, b"\xD2\x76\x00\x01\x24\x01")
+        r = self.icc_send_cmd(cmd_data)
+        if len(r) < 2:
+            raise ValueError(r)
+        sw = r[-2:]
+        r = r[0:-2]
+        if sw[0] == 0x61:
+            self.cmd_get_response(sw[1])
+            return True
+        elif sw[0] == 0x90 and sw[1] == 0x00:
+            return True
+        else:
             raise ValueError("%02x%02x" % (sw[0], sw[1]))
-        return True
 
     def cmd_get_data(self, tagh, tagl):
         cmd_data = iso7816_compose(0xca, tagh, tagl, b"")
@@ -341,8 +347,8 @@ class gnuk_token(object):
             raise ValueError("%02x%02x" % (sw[0], sw[1]))
         return True
 
-    def cmd_reset_retry_counter(self, how, data):
-        cmd_data = iso7816_compose(0x2c, how, 0x00, data)
+    def cmd_reset_retry_counter(self, how, who, data):
+        cmd_data = iso7816_compose(0x2c, how, who, data)
         sw = self.icc_send_cmd(cmd_data)
         if len(sw) != 2:
             raise ValueError(sw)