What is SHA-512's input space, taking into account variable message size? The SHA-512 hash function accepts any message from a single bit to $2^{128}$ bits. Because the function takes into account the message length, I can't just represent every message as a $2^{128}$-bit integer. I'm sure this is a very basic question, but my math background is limited so this isn't coming easily to me.
How do I calculate the number of distinct inputs?
There is one zero-length message, two 1 bit long messages, four 2 bit long messages, eight 3 bit long messages, and so on. Since these messages are distinct, you can simply use the formula:

$$1 + 2 + 4 + 8 + \dots + 2^{n-1} = 2^n-1$$

Note that the maximum message length is the same as the maximum value of a 128-bit integer, ie. $2^{128} - 1$, not $2^{128}$. That makes $n-1 = 2^{128} - 1$, so $n = 2^{128}$. That makes the total number of distinct inputs

$$2^{(2^{128}-1)} - 1 $$