SHA algorithim with different hash value

I am new in hash cryptography. I am trying to build the sha256 hardware accelerator. I am thinking about using the different hash value to optimize the performance. I am trying to fetch custom hash initial value which already computed sometime ago. Does this approach valid and what problem i would get.

Thanks

• I doubt that this question can be answered in its current state. It is very unclear what exactly you are trying to achieve. Maybe elaborate a bit on what you are trying to do? – Maeher Mar 7 '18 at 4:23
• My hardware accelerator use rocc interface given by rocketchip generator[link] ( github.com/freechipsproject/rocket-chip). accelerator could directly connect to core and cache. What i m trying to avoid memory halt when using the accelerator. SO i am thinking about processing the hash in stage wise – ARK91 Mar 7 '18 at 4:31

I'll assume that you are thinking this way:

I am hashing a series of values that share the same prefix $X$ (which is a multiple of 64 bytes in length), that is, you are computing:

\begin{gather*} \operatorname{SHA256}(X \mathbin\Vert A) \\ \operatorname{SHA256}(X \mathbin\Vert B) \\ \vdots \\ \operatorname{SHA256}(X \mathbin\Vert B) \end{gather*}

and you are wondering "can I just compute the internal SHA256 state immediately after X, and then just use that as the "initial SHA256 state" when I process the strings $A, B, \dots, Z$?

Answer: yes, absolutely. In fact, this is fairly common practice when these sorts of hashes are needed (which happens more than you'd expect; for example, when computing HMAC's).

What problem I would get?

One thing you need to be careful is in the length field in the SHA-256 padding at the end; it needs to include the length of the entire message (including $X$), not just the message you just processed.