From: SourceForge.net <no...@so...> - 2011-10-22 16:55:03
|
Bugs item #3083586, was opened at 2010-10-08 10:36 Message generated for change (Comment added) made by jdaussel You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=957072&aid=3083586&group_id=196342 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: PCSC wrapper Group: None >Status: Closed >Resolution: Fixed Priority: 5 Private: No Submitted By: Frank Morgner (frankmorgner) Assigned to: jean-daniel aussel (jdaussel) Summary: duplicated status bytes in resp Initial Comment: When receiving longer responses (tested with data+sw1+sw2=250 bytes), the status bytes are still in the data part of sendCommandAPDU() here example code: self.reader = smartcard.System.listReaders()[readernum] self.session = smartcard.Session(self.reader) rapdu, sw1, sw2 = self.session.sendCommandAPDU(apdu) here a response i received: SW: 81 01 FE E9 2B 04 04 41 04 A3 E8 EB 3C C1 CF E7 B7 73 22 13 B2 3A 65 61 49 AF A1 42 C4 7A AF BC 2B 79 A1 91 56 2E 13 05 F4 2D 99 6C 82 34 39 C5 6D 7F 7B 22 E1 46 44 41 7E 69 BC B6 DE 39 D0 27 00 1D AB E8 F3 5B 25 C9 BE 02 21 00 A9 FB 57 DB A1 EE A9 BC 3E 66 0A 90 9D 83 8D 71 8C 39 7A A3 B5 61 A6 F7 90 1E 0E 82 97 48 56 A7 02 01 01 30 81 FE 06 09 04 00 7F 00 07 02 02 04 02 30 81 F0 06 0B 04 00 7F 00 07 01 01 05 02 02 02 30 81 E0 02 01 01 30 2C 06 07 2A 86 48 CE 3D 01 01 02 21 00 A9 FB 57 DB A1 EE A9 BC 3E 66 0A 90 9D 83 8D 72 6E 3B F6 23 D5 26 20 28 20 13 48 1D 1F 6E 53 77 30 44 04 20 A9 FB 57 DB A1 EE A9 BC 3E 66 0A 90 9D 83 8D 72 6E 3B F6 23 D5 26 20 28 20 13 48 1D 1F 6E 53 74 04 20 66 2C 61 C4 30 D8 4E A4 FE 66 A7 73 3D 0B 76 B7 BF 90 00 this results in rapdu, sw1, sw2: [129, 1, 254, 233, 43, 4, 4, 65, 4, 163, 232, 235, 60, 193, 207, 231, 183, 115, 34, 19, 178, 58, 101, 97, 73, 175, 161, 66, 196, 122, 175, 188, 43, 121, 161, 145, 86, 46, 19, 5, 244, 45, 153, 108, 130, 52, 57, 197, 109, 127, 123, 34, 225, 70, 68, 65, 126, 105, 188, 182, 222, 57, 208, 39, 0, 29, 171, 232, 243, 91, 37, 201, 190, 2, 33, 0, 169, 251, 87, 219, 161, 238, 169, 188, 62, 102, 10, 144, 157, 131, 141, 113, 140, 57, 122, 163, 181, 97, 166, 247, 144, 30, 14, 130, 151, 72, 86, 167, 2, 1, 1, 48, 129, 254, 6, 9, 4, 0, 127, 0, 7, 2, 2, 4, 2, 48, 129, 240, 6, 11, 4, 0, 127, 0, 7, 1, 1, 5, 2, 2, 2, 48, 129, 224, 2, 1, 1, 48, 44, 6, 7, 42, 134, 72, 206, 61, 1, 1, 2, 33, 0, 169, 251, 87, 219, 161, 238, 169, 188, 62, 102, 10, 144, 157, 131, 141, 114, 110, 59, 246, 35, 213, 38, 32, 40, 32, 19, 72, 29, 31, 110, 83, 119, 48, 68, 4, 32, 169, 251, 87, 219, 161, 238, 169, 188, 62, 102, 10, 144, 157, 131, 141, 114, 110, 59, 246, 35, 213, 38, 32, 40, 32, 19, 72, 29, 31, 110, 83, 116, 4, 32, 102, 44, 97, 196, 48, 216, 78, 164, 254, 102, 167, 115, 61, 11, 118, 183, 191, 144, 0] 144 0 as you can see, the last 144, 0 should be removed from the list of databytes ---------------------------------------------------------------------- >Comment By: jean-daniel aussel (jdaussel) Date: 2011-10-22 18:55 Message: this is the intended behavior; the status words are included in the response. If the response has more than two words (i.e. there is something else than the status words), sendCommandAPDU returns a tuple: (response,sw1,sw2), but response always contain the two status words at the end of the list. ---------------------------------------------------------------------- Comment By: Ludovic Rousseau (ludov) Date: 2011-10-19 20:50 Message: Fixing the "problem" is easy. Just remove the 3 lines of code: if len(response) > 2: response.append(sw1) response.append(sw2) ---------------------------------------------------------------------- Comment By: Ludovic Rousseau (ludov) Date: 2011-10-19 20:49 Message: The problem is not related to the response size. I have the same behavior even for short responses. According to the source code this is the intended behavior. Source code is: def sendCommandAPDU(self, command): """Send an APDU command to the connected smartcard. command: list of APDU bytes, e.g. [0xA0, 0xA4, 0x00, 0x00, 0x02] returns a tuple (response, sw1, sw2) where response is the APDU response sw1, sw2 are the two status words """ response, sw1, sw2 = self.cs.connection.transmit(command) if len(response) > 2: response.append(sw1) response.append(sw2) return response, sw1, sw2 ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=957072&aid=3083586&group_id=196342 |