'Derive various session keys from the given `masterKey\'.
The argument `masterKey\' is used to derive two session keys and nonces
for AES-CTR and two HMAC keys.  The derivation is done using
HKDF-SHA256.'

def deriveSecrets(self, masterKey):

    assert (len(masterKey) == const.MASTER_KEY_LENGTH)
    hkdf = mycrypto.HKDF_SHA256(masterKey, '', ((32 * 4) + (8 * 2)))
    okm = hkdf.expand()
    assert (len(okm) >= ((32 * 4) + (8 * 2)))
    self.sendCrypter.setSessionKey(okm[0:32], okm[32:40])
    self.recvCrypter.setSessionKey(okm[40:72], okm[72:80])
    self.sendHMAC = okm[80:112]
    self.recvHMAC = okm[112:144]
    if self.weAreServer:
        (self.sendHMAC, self.recvHMAC) = (self.recvHMAC, self.sendHMAC)
        (self.sendCrypter, self.recvCrypter) = (self.recvCrypter, self.sendCrypter)
