예제 #1
0
 def transmit(self, apdu):
     if apdu.ins == "A4":
         if apdu.data == "A0000002471001":
             #Passport AID
             pass
         else:
             #SelectFile
             try:
                 if self._file:
                     self._file.close()
                 self._file = open(self.readerNum + converter.to(self.format, apdu.data) + self.ext, "rb")
             except Exception as msg:
                 return ResponseAPDU(str(msg), 0x6A, 0x82)
         return ResponseAPDU("", 0x90, 0x00)
     
     elif apdu.ins == "B0":
         #ReadBinary
         try:
             offset = hexRepToHex(apdu.p1 + apdu.p2)
             self._file.seek(offset)
             res = self._file.read(hexRepToHex(apdu.le))
             return ResponseAPDU(res, 0x90, 0x00)
         except Exception as msg:
             return ResponseAPDU(str(msg), 0x6A, 0x88)
         
     #Function not supported
     return ResponseAPDU("", 0x6A, 0x81)
예제 #2
0
    def dumpDG(self, dg, format=converter.types.FID):
        """
        Save the specified dataGroup on the HDD.

        @param dg: A filled dataGroup object
        @type dg: A dataGroup object
        @param format: Specify the file name format. (FID, TAG, SEF,...)
        @type format: An element out of the converter.types enumeration.
        """
        f = open(self._path + converter.to(format, dg.tag) + self._ext, "wb")
        f.write(dg.file)
        f.close()
예제 #3
0
 def dumpDG(self, dg, format=converter.types.FID):
     """  
     Save the specified dataGroup on the HDD.
     
     @param dg: A filled dataGroup object
     @type dg: A dataGroup object
     @param format: Specify the file name format. (FID, TAG, SEF,...)
     @type format: An element out of the converter.types enumeration.
     """
     f = open(self._path + converter.to(format, dg.tag) + self._ext, "wb")
     f.write(dg.file)
     f.close()
예제 #4
0
 def transmit(self, apdu):
     if apdu.ins == "A4":
         if apdu.data == "A0000002471001":
             #Passport AID
             pass
         else:
             #SelectFile
             try:
                 if self._file:
                     self._file.close()
                 self._file = open(self.readerNum + converter.to(self.format, apdu.data) + self.ext, "rb")
             except Exception, msg:
                 return ResponseAPDU(str(msg), 0x6A, 0x82)
         return ResponseAPDU("", 0x90, 0x00)
예제 #5
0
 def transmit(self, apdu):
     if apdu.ins == "A4":
         if apdu.data == "A0000002471001":
             #Passport AID
             pass
         else:
             #SelectFile
             try:
                 if self._file:
                     self._file.close()
                 self._file = open(
                     self.readerNum + converter.to(self.format, apdu.data) +
                     self.ext, "rb")
             except Exception, msg:
                 return ResponseAPDU(str(msg), 0x6A, 0x82)
         return ResponseAPDU("", 0x90, 0x00)