Exemple #1
0
    def authenticationAndEstablishmentOfSessionKeys(self, mrz):
        """
        Execute the complete BAC process:
            - Derivation of the document basic acces keys
            - Mutual authentication
            - Derivation of the session keys
            
        @param mrz: The machine readable zone of the passport
        @type mrz: an MRZ object
        @return: A set composed of (KSenc, KSmac, ssc)   
        
        @raise MRZException: I{The mrz length is invalid}: The mrz parameter is not valid.
        @raise BACException: I{Wrong parameter, mrz must be an MRZ object}: The parameter is invalid.
        @raise BACException: I{The mrz has not been checked}: Call the I{checkMRZ} before this method call.
        @raise BACException: I{The sublayer iso7816 is not available}: Check the object init parameter, it takes an iso7816 object
        """

        if type(mrz) != type(MRZ(None)):
            raise BACException("Wrong parameter, mrz must be an MRZ object")

        if not mrz.checked:
            mrz.checkMRZ()

        if type(self._iso7816) != type(Iso7816(None)):
            raise BACException("The sublayer iso7816 is not available")

        try:
            self.derivationOfDocumentBasicAccesKeys(mrz)
            rnd_icc = self._iso7816.getChallenge()

            cmd_data = self.authentication(rnd_icc)
            data = self._mutualAuthentication(cmd_data)
            return self.sessionKeys(data)
        except Exception as msg:
            raise msg
Exemple #2
0
 def initIso7816(self):
     try:
         if not self._iso7816:
             r = readerAbstract.waitForCard()
             self._iso7816 = Iso7816(r)
     except Exception, msg:
         tkMessageBox.showerror("Error: Initialisation of ISO7816",
                                str(msg))
    def __init__(self, iso7816):
        Logger.__init__(self, "SIGN EVERYTHING ATTACK")
        self._iso7816 = iso7816

        if type(self._iso7816) != type(Iso7816(None)):
            raise SignEverythingException("The sublayer iso7816 is not available")

        self._iso7816.rstConnection()

        self._bac = bac.BAC(iso7816)
        self._openssl = OpenSSL()
    def __init__(self, iso7816):
        Logger.__init__(self, "AA TRACEABILITY")
        self._iso7816 = iso7816

        if type(self._iso7816) != type(Iso7816(None)):
            raise AATraceabilityException(
                "The sublayer iso7816 is not available")

        self._iso7816.rstConnection()

        self._bac = None
    def __init__(self, iso7816, mrz=None):
        Logger.__init__(self, "MAC TRACEABILITY")
        self._iso7816 = iso7816
        self._mrz = mrz

        if type(self._iso7816) != type(Iso7816(None)):
            raise MacTraceabilityException(
                "The sublayer iso7816 is not available")

        self._iso7816.rstConnection()

        self._bac = BAC(iso7816)
    def __init__(self, iso7816, activateReader=True):
        Logger.__init__(self, "BRUTE FORCE")

        if activateReader:
            self._iso7816 = iso7816
            if type(self._iso7816) != type(Iso7816(None)):
                raise MacTraceabilityException("The sublayer iso7816 is not available")
            self._iso7816.rstConnection()
            #self._bac = BAC(iso7816)

        self._id_low = None
        self._id_high = None
        self._dob_low = None
        self._dob_high = None
        self._exp_date_low = None
        self._exp_date_high = None

        self._weighting = [7,3,1]
        self._id_values = {'<':0, '0':0, '1':1, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9, 'A':10, 'B':11, 'C':12, 'D':13, 'E':14, 'F':15, 'G':16, 'H':17, 'I':18, 'J':19, 'K':20, 'L':21, 'M':22, 'N':23, 'O':24, 'P':25, 'Q':26, 'R':27, 'S':28, 'T':29, 'U':30, 'V':31, 'W':32, 'X':33, 'Y':34, 'Z':35}
        self._inv_id_values = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
Exemple #7
0
    def __init__(self, iso7816, path="error.dat"):
        Logger.__init__(self, "ERROR FINGERPRINTING")
        self._iso7816 = iso7816

        if type(self._iso7816) != type(Iso7816(None)):
            raise MacTraceabilityException("The sublayer iso7816 is not available")

        self._iso7816.rstConnection()

        self._path = path

        if os.path.exists(path):
            with open(path, 'rb') as file_errors:
                my_unpickler = pickle.Unpickler(file_errors)
                self.errors = my_unpickler.load()
        else:
            self.errors = { "0000000000": { "0x6d 0x0": {   "BEL": ["2009", "2011"],
                                                            "FRA": ["2010"]
                                                        }
                                          }
                          }