Example #1
0
 def __doMutualAuth(self, args):
     scp, scpi, sencKey, smacKey, dekKey = args
     
     if not self.__checkContext(): return
     if not self.__checkCardInfo(): return
     
     self.__handler.handleActionBegin("do mutual authentication")
     
     try:
         self.__handler.handleLog('doMutualAuth(): Start...')
         # Select Card Manager first;
         gp.selectApplication(self.__context, self.__cardInfo, '')
         # Get SCP informations;
         if scp == -1 and scpi == -1:
             scp, scpi = gp.getSCPDetails(self.__context, self.__cardInfo)
             self.__handler.handleSCPInfo(scp, scpi)
         
         if (scp in (1, 2)):
             if (len(sencKey) != 16) or (len(smacKey) != 16) or (len(dekKey) != 16):
                 self.__handler.handleLog('The key of SCP01 shall be 16 bytes long.', wx.LOG_Warning)
                 return
         elif scp == 3:
             keyLen1 = len(sencKey)
             keyLen2 = len(smacKey)
             keyLen3 = len(dekKey)
             if (keyLen1 not in (16, 24, 32)) or (keyLen2 not in (16, 24, 32)) or (keyLen3 not in (16, 24, 32)):
                 self.__handler.handleLog('The key of SCP03 shall be (16 or 24 or 32) bytes long.', wx.LOG_Warning)
                 return
         
         kvn = 0
         self.__securityInfo = gp.mutualAuthentication(self.__context, self.__cardInfo, None, sencKey, smacKey, dekKey, kvn, 0, scp, scpi, 0, 0)
         self.__handler.handleLog('doMutualAuth(): Succeeded.', wx.LOG_Info)
     except Exception, e:
         self.__handler.handleException(e)
Example #2
0
    def __doMutualAuth(self, args):
        scp, scpi, sencKey, smacKey, dekKey = args

        if not self.__checkContext(): return
        if not self.__checkCardInfo(): return

        self.__handler.handleActionBegin("do mutual authentication")

        try:
            self.__handler.handleLog('doMutualAuth(): Start...')
            # Select Card Manager first;
            gp.selectApplication(self.__context, self.__cardInfo, '')
            # Get SCP informations;
            if scp == -1 and scpi == -1:
                scp, scpi = gp.getSCPDetails(self.__context, self.__cardInfo)
                self.__handler.handleSCPInfo(scp, scpi)

            if (scp in (1, 2)):
                if (len(sencKey) != 16) or (len(smacKey) != 16) or (len(dekKey)
                                                                    != 16):
                    self.__handler.handleLog(
                        'The key of SCP01 shall be 16 bytes long.',
                        wx.LOG_Warning)
                    return
            elif scp == 3:
                keyLen1 = len(sencKey)
                keyLen2 = len(smacKey)
                keyLen3 = len(dekKey)
                if (keyLen1 not in (16, 24, 32)) or (keyLen2 not in (
                        16, 24, 32)) or (keyLen3 not in (16, 24, 32)):
                    self.__handler.handleLog(
                        'The key of SCP03 shall be (16 or 24 or 32) bytes long.',
                        wx.LOG_Warning)
                    return

            kvn = 0
            self.__securityInfo = gp.mutualAuthentication(
                self.__context, self.__cardInfo, None, sencKey, smacKey,
                dekKey, kvn, 0, scp, scpi, 0, 0)
            self.__handler.handleLog('doMutualAuth(): Succeeded.', wx.LOG_Info)
        except Exception, e:
            self.__handler.handleException(e)
Example #3
0
 def getSCPDetails(self):
     self.__checkContext()
     self.__checkCardInfo()
     return gp.getSCPDetails(self.__context, self.__cardInfo)