def setCiphering(self): try: self.initIso7816() KSenc = hexRepToBin(self.customKencForm.get()) KSmac = hexRepToBin(self.customKmacForm.get()) ssc = hexRepToBin(self.customSscForm.get()) sm = securemessaging.SecureMessaging(KSenc, KSmac, ssc) self._iso7816.setCiphering(sm) self.writeToLog("CIPHERING SET:\n{0}".format(sm)) except Exception, msg: tkMessageBox.showerror("Error: Set ciphering", str(msg))
def doBasicAccessControl(self): """ Execute the basic acces control protocol and set up the secure messaging. @return: A True if the BAC execute correctly @raise bacException: If an error occur during the process @raise EPassportException: If the mrz is not initialized. """ if self._mrz == None: raise EPassportException("The object must be initialized with the ePassport MRZ") (KSenc, KSmac, ssc) = self._bac.authenticationAndEstablishmentOfSessionKeys(self._mrz) sm = securemessaging.SecureMessaging(KSenc, KSmac, ssc) sm.register(self._logFct) return self._iso7816.setCiphering(sm)
def performBAC(self): try: if self.mrz.buildMRZ(): self.reset() self.init() basic_access_control = bac.BAC(self._iso7816) ( KSenc, KSmac, ssc ) = basic_access_control.authenticationAndEstablishmentOfSessionKeys( mrz.MRZ(self.mrz.buildMRZ())) sm = securemessaging.SecureMessaging(KSenc, KSmac, ssc) self._iso7816.setCiphering(sm) self.writeToLog("CIPHERING SET:\n{0}".format(sm)) else: tkMessageBox.showerror("Error: BAC", "You have to set the proper MRZ first") except Exception, msg: tkMessageBox.showerror("Error: BAC", str(msg))