'Setup the crypto from the calculated shared secret, and complete the
obfs3 handshake.'

def _read_handshake_post_dh(self, shared_secret, other_pubkey, data):

    self.shared_secret = shared_secret
    log_prefix = 'obfs3:_read_handshake_post_dh()'
    self.send_crypto = self._derive_crypto(self.send_keytype)
    self.recv_crypto = self._derive_crypto(self.recv_keytype)
    self.other_magic_value = hmac_sha256.hmac_sha256_digest(self.shared_secret, self.recv_magic_const)
    padding_length = random.randint(0, (MAX_PADDING / 2))
    magic = hmac_sha256.hmac_sha256_digest(self.shared_secret, self.send_magic_const)
    message = ((rand.random_bytes(padding_length) + magic) + self.send_crypto.crypt(self.queued_data))
    self.queued_data = ''
    self.circuit.downstream.write(message)
    self.state = ST_SEARCHING_MAGIC
    if (len(data) > 0):
        self._scan_for_magic(data)
