# How to calculate entropy of a combined key

I know how to calculate the entropy of a key that relates to its selection process. For example if the key space is $1000$, entropy of a randomly chosen key is $1000$. Suppose now you have two keys $X$ and $Y$. The finale key $Z$ is a concatenation of $X$ and $Y$. There are two ways to combine. One is to use XOR and other way is to use a Key Based Key Derivation Function (KBKDF) such as HKDF. I want to know how to calculate the entropy of $Z$ when…

• $Z$ = $X$ XOR $Y$
• $Z$ = HKDF($X$,$Y$)

In the XOR case should I use mutual information of $X$ and $Y$?

With proper hashing the entopy of $Z$ is roughly the sum of both individual entropies, capped to the strength of the hash-function. For SHA-256 the limit is 256 bits, for SHA-512 it's 512 bits. Since entropy above 256 bits is meaningless, this isn't a practical limitation.
For XOR computing the entropy of $Z$ is tricky and depends on how your keys are distributed. It's probably only as strong as the stronger of the two key, which is clearly worse than the sum. If the keys are correlated it might even fail catastrophically.