# Can we map SHA-256 output bits to fixed-length input bits?

If I have a set of $N$-byte input values to be hashed using SHA-256, then what are the mapping functions for each of the 256 bits of the output?

It seems to me that hashes are one-way partially because we don't know the input size, but if we did know the size to be $N$, then I expect to find a generalized mapping functions for each of the 256 output bits as functions of the $N$ input bits.

To be clear, I am not trying to find an input for a given output - I am happy for a mapping to still be a 1-way function. Say, for 1000 bits of input, each output bit may be a function of all 1000 bits, or perhaps fewer, or perhaps with extra variables (S-box etc):

ox = f(i0, i1,...1N, s0, s1,...)
for the Xth output bit as a function of up to $N$ input bits and other variables.

In theory, should this be possible? If not, why not? If yes, what are some tips to learning all 256 mapping functions from the algorithm?

• Hint: Even restricted to a fixed input size like 256 bits we have no reason to doubt SHA-256's preimage resistance. Try plugging the SHA-256 formula into a SAT solver and see how far you get before the terrible fabled oom killer comes for you in the night, or you get bored of waiting. Dec 17, 2017 at 6:07
• Thanks @SqueamishOssifrage. First off - love the name! Secondly, the SAT Solver idea was good, and has been discussed on SE here and externally here. I'm linking them in this comment for future readers. Thanks for the insight. Dec 18, 2017 at 5:06

For attacks usually a reduced number of rounds are used, trying to expand them to the full hash later. And if your input $N$ is small enough then you could simply use brute force or an attack using a rainbow table... but that's about it.