# What do the inputs of hash_df look like?

I am making an implementation of hash_df (NIST documentation found in SP800-90A.pdf on page 67)

I found “Does hash_df use binary or an ASCII hexadecimal representation for numbers to be passed to the hash function?” which explained a few things, but im still not completely sure that I have it right. I am having trouble with part 4.1 under Hash_df Process as seen below

temp = temp || Hash (counter || no_of_bits_to_return || input_string)


Counter is expected to be a 1 byte binary value
no_of_bits_to_return is a 4 byte big-endian binary value
input_string is the concatenation of entropy_input, nonce and personalization_string.

so as an example if counter = 2, no_of_bits_to_return = 16 and input_string = "8581f93h" the later part of the function would look like this: (|| is concatenation. The no_of_bits_to_return binary value in my example could be incorrect. I need to get more familiar with big-endian I just put this one in a converter)

hash(00000010 || 16000000 || 0011100000110101001110000011000101100110 001110010011001101101000)


Is this correct as per the NIST SP 800-90A documentation? I can’t find the documentation to confirm my assumptions and I am afraid I am horribly wrong.

• no_of_bits_to_return is bigendian, and so 16 would be encoded as (in binary) 00000000000000000000000000010000. All 'bigendian' means is 'big end first', that is, the msbyte is the first one, and the lsbyte is the last one. – poncho Feb 1 '17 at 23:15