

def _make_secret_payload(self, encoded_secret):
    'Builds payload out of binary secret.\n\n    Args:\n      encoded_secret: Binary form of secret (any type).\n\n    Returns:\n      Binary value to be used as the secret payload.\n    '
    servercert = M2Crypto.X509.load_cert_der_string(self.ssl.getpeercert(True))
    clientcert = M2Crypto.X509.load_cert(self.certfile)

    def get_key_pair(c):
        return [remove_null_bytes(v[4:]) for v in c.get_pubkey().get_rsa().pub()]

    def remove_null_bytes(v):
        return ''.join(itertools.dropwhile((lambda x: (x == '\x00')), v))
    (sexp, smod) = get_key_pair(servercert)
    (cexp, cmod) = get_key_pair(clientcert)
    digest = hashlib.sha256()
    digest.update(cmod)
    digest.update(cexp)
    digest.update(smod)
    digest.update(sexp)
    digest.update(encoded_secret[(len(encoded_secret) // 2):])
    return digest.digest()

dataset/ETHPy150Open stevenle/googletv-anymote/googletv/__init__.py PairingProtocol._make_secret_payload/original