'Create and return a ready-to-be-sent UniformDH handshake.
The returned handshake data includes the public key, pseudo-random
padding, the mark and the HMAC.  If a UniformDH object has not been
initialised yet, a new instance is created.'

def createHandshake(self, srvState=None):

    assert (self.sharedSecret is not None)
    log.debug('Creating    UniformDH    handshake    message.')
    if (self.udh is None):
        self.udh = obfs3_dh.UniformDH()
    publicKey = self.udh.get_public()
    assert ((const.MAX_PADDING_LENGTH - const.PUBLIC_KEY_LENGTH) >= 0)
    padding = mycrypto.strongRandom(random.randint(0, (const.MAX_PADDING_LENGTH - const.PUBLIC_KEY_LENGTH)))
    mark = mycrypto.HMAC_SHA256_128(self.sharedSecret, publicKey)
    if (self.echoEpoch is None):
        epoch = util.getEpoch()
    else:
        epoch = self.echoEpoch
        log.debug('Echoing    epoch    rather    than    recreating    it.')
    mac = mycrypto.HMAC_SHA256_128(self.sharedSecret, (((publicKey + padding) + mark) + epoch))
    if (self.weAreServer and (srvState is not None)):
        log.debug(("Adding    the    HMAC    authenticating    the    server's    UniformDH    message    to    the    replay    table:    %s." % mac.encode('hex')))
        srvState.registerKey(mac)
    return (((publicKey + padding) + mark) + mac)
