def hkdf(self, chaining_key, input_key_material, dhlen=64):
        """Hash-based key derivation function

        Takes a ``chaining_key'' byte sequence of len HASHLEN, and an
        ``input_key_material'' byte sequence with length either zero
        bytes, 32 bytes or dhlen bytes.

        Returns two byte sequences of length HASHLEN"""

        if len(chaining_key) != self.HASHLEN:
            raise HashError("Incorrect chaining key length")
        if len(input_key_material) not in (0, 32, dhlen):
            raise HashError("Incorrect input key material length")
        temp_key = self.hmac_hash(chaining_key, input_key_material)
        output1 = self.hmac_hash(temp_key, b'\x01')
        output2 = self.hmac_hash(temp_key, output1 + b'\x02')
        return output1, output2