def createTicketMessage(rawTicket, HMACKey):
 assert (len(rawTicket) == const.TICKET_LENGTH)
 assert (len(HMACKey) == const.TICKET_HMAC_KEY_LENGTH)
 padding = mycrypto.strongRandom(random.randint(0, (const.MAX_PADDING_LENGTH - const.TICKET_LENGTH)))
 mark = mycrypto.HMAC_SHA256_128(HMACKey, rawTicket)
 hmac = mycrypto.HMAC_SHA256_128(HMACKey, (((rawTicket + padding) + mark) + util.getEpoch()))
 return (((rawTicket + padding) + mark) + hmac)

def createTicketMessage ( rawTicket , HMACKey ) : assert ( len ( rawTicket ) == const . TICKET_LENGTH ) assert ( len ( HMACKey ) == const . TICKET_HMAC_KEY_LENGTH ) padding = mycrypto . strongRandom ( random . randint ( 0 , ( const . MAX_PADDING_LENGTH - const . TICKET_LENGTH ) ) ) mark = mycrypto . HMAC_SHA256_128 ( HMACKey , rawTicket ) hmac = mycrypto . HMAC_SHA256_128 ( HMACKey , ( ( ( rawTicket + padding ) + mark ) + util . getEpoch ( ) ) ) return ( ( ( rawTicket + padding ) + mark ) + hmac )
create and return a ready-to-be-sent ticket authentication message .