I came up with this question while unit testing a function that includes an HMAC. What is the expected behavior of an HMAC with a well-defined key and a set of data with no elements in it? Is there such a concept as a "null HMAC"?
For example,
byte[] key = RNG.RandomData(32);
byte[] data = { };
byte[] hmac_result = HMAC.HMAC(key, data)
Ignoring the specific language or library I used, is hmac_result
well-defined (based on the value of the key or specific HMAC algorithm used), or should the function return an exception?
I'm looking for an answer backed in theory, as I could believe different HMAC implementations could choose to raise an exception on questionable input data.
If the answer depends on the hash function used, what factors would lead to the result being well-defined or not?