Mutually authenticate with a FeliCa Lite-S Tag.

        FeliCa Lite-S supports enhanced security functions, one of
        them is the mutual authentication performed by this
        method. The first part of mutual authentication is to
        authenticate the tag with :meth:`FelicaLite.authenticate`. If
        successful, the shared session key is used to generate the
        integrity check value for write operation to update a specific
        memory block. If that was successful then the tag is ensured
        that the reader has the correct card key.

        After successful authentication the
        :meth:`~FelicaLite.read_with_mac` and :meth:`write_with_mac`
        methods can be used to read and write data such that it can
        not be falsified on transmission.

def authenticate(self, password):
        """Mutually authenticate with a FeliCa Lite-S Tag.

        FeliCa Lite-S supports enhanced security functions, one of
        them is the mutual authentication performed by this
        method. The first part of mutual authentication is to
        authenticate the tag with :meth:`FelicaLite.authenticate`. If
        successful, the shared session key is used to generate the
        integrity check value for write operation to update a specific
        memory block. If that was successful then the tag is ensured
        that the reader has the correct card key.

        After successful authentication the
        :meth:`~FelicaLite.read_with_mac` and :meth:`write_with_mac`
        methods can be used to read and write data such that it can
        not be falsified on transmission.

        """
        if super(FelicaLiteS, self).authenticate(password):
            # At this point we have achieved internal authentication,
            # i.e we know that the tag has the same card key as in
            # password. We now reset the authentication status and do
            # external authentication to assure the tag that we have
            # the right card key.
            self._authenticated = False
            self.read_from_ndef_service = self.read_without_mac
            self.write_to_ndef_service = self.write_without_mac

            # To authenticate to the tag we write a 01h into the
            # ext_auth byte of the state block (block 0x92). The other
            # bytes of the state block can be all set to zero.
            self.write_with_mac("\x01" + 15*"\0", 0x92)

            # Now read the state block and check the value of the
            # ext_auth to see if we are authenticated. If it's 01h
            # then we are, otherwise not.
            if self.read_with_mac(0x92)[0] == 0x01:
                log.debug("mutual authentication completed")
                self._authenticated = True
                self.read_from_ndef_service = self.read_with_mac
                self.write_to_ndef_service = self.write_with_mac
            else:
                log.debug("mutual authentication failed")

        return self._authenticated