2
$\begingroup$

I have a hardware engine for SHA256 which can process 64K of data, but the input data size I am getting is around 1MB. What should I do to process 1MB size.

What should be my input after 1st 64KB and what will be my IV (initial vector)? Can anyone provide any idea?

$\endgroup$
  • 6
    $\begingroup$ That is hard to tell without knowing specific details about your unidentified SHA-256 hardware engine, but since the average cryptographic hardware tends to come with a user manual… What does the manual say? $\endgroup$ – e-sushi Jan 18 '16 at 7:28
4
$\begingroup$

Most likely, the hardware engine has an API accepting an IV of 256 bits (32 bytes) and a data block of some size multiple of 512 bits (64 bytes), and returns a result of 32 bytes.

Given that SHA-256 is a Merkle-Damgård hash, in order to chain invocations of that API, you want to pass the SHA-256 IV (given by FIPS 186-4 section 5.3.3) as the IV of the first call, and the result of the previous call as the IV of the next invocation. The last result returned by the API will be the hash.

Assuming the API does not perform the padding, the data blocks passed to successive invocations shall be the padded message (that is the message of $S$ bits followed by a single bit at 1, then $511-(S+64\bmod512)$ bit(s) at 0, then $S$ on 64 bits in big-endian binary), truncated into blocks suitable for the API, in the order they have in the padded message.

If the blocks passed to the API could only have 64kB size, that API would be usable to process the whole message only when $2^{19}-576\le S\bmod 2^{19}<2^{19}-64$; otherwise, some of the end of the computation would need to be done in software.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.