コード例 #1
0
    async def start_pairing(self) -> None:
        """Start the pairing process.

        This method will show the expected PIN on screen.
        """
        resp = await self.http.post("/pair-pin-start",
                                    headers=_AIRPLAY_HEADERS)
        if resp.code != 200:
            raise AuthenticationError("pair start failed")
コード例 #2
0
    async def start_authentication(self):
        """Start the authentication process.

        This method will show the expected PIN on screen.
        """
        _, code = await self.http.post_data("pair-pin-start",
                                            headers=_AIRPLAY_HEADERS)
        if code != 200:
            raise AuthenticationError("pair start failed")
コード例 #3
0
    async def _send(self, data, step):
        headers = copy(_AIRPLAY_HEADERS)
        headers["Content-Type"] = "application/octet-stream"

        resp, code = await self.http.post_data("pair-verify",
                                               data=data,
                                               headers=headers)
        if code != 200:
            raise AuthenticationError("{0} failed with code {1}".format(
                step, code))
        return resp
コード例 #4
0
    async def _send_plist(self, step, **kwargs):
        plist = dict((str(k), v) for k, v in kwargs.items())

        headers = copy(_AIRPLAY_HEADERS)
        headers["Content-Type"] = "application/x-apple-binary-plist"

        # TODO: For some reason pylint does not find FMT_BINARY, why?
        # pylint: disable=no-member
        resp, code = await self.http.post_data("pair-setup-pin",
                                               data=plistlib.dumps(
                                                   plist,
                                                   fmt=plistlib.FMT_BINARY))
        if code != 200:
            raise AuthenticationError("{0} failed with code {1}".format(
                step, code))
        return resp
コード例 #5
0
ファイル: srp.py プロジェクト: postlund/pyatv
    def step2(self, pub_key, salt):
        """Second authentication step."""
        pk_str = binascii.hexlify(pub_key).decode()
        salt = binascii.hexlify(salt).decode()
        client_session_key, _, _ = self.session.process(pk_str, salt)
        _LOGGER.debug("Client session key: %s", client_session_key)

        # Generate client public and session key proof.
        client_public = self.session.public
        client_session_key_proof = self.session.key_proof
        _LOGGER.debug("Client public: %s, proof: %s", client_public,
                      client_session_key_proof)

        if not self.session.verify_proof(self.session.key_proof_hash):
            raise AuthenticationError("proofs do not match (mitm?)")
        return client_public, client_session_key_proof