This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM2634-Q1: How to generate HASH digest for several parts of content in continuously

Part Number: AM2634-Q1
Other Parts Discussed in Thread: AM2634

Hi, experts,

Customers want to do HASH on sub-set of image for each core in SBL. The multi-core image is read into SRAM, and specific sub-set of image for each core is used for HASH operation.

For example, four R5F cores are needed in the use case, and the combined image for all these four cores are loaded by SBL. The first 256 bytes of image of each R5F core are used for HASH. Not the whole image are used for HASH because of time saving. Correspondingly, the expected HASH digest is generated on PC, where the 4 * 256 bytes (4 R5F cores, 256 bytes from image for each core) is processed continuously as a 1024 bytes data block.

Then, in the AM2634 side, as these four 256 bytes data blocks are not stored in consecutive address space, the DTHE_SHA_compute() API is called four times, and each time it uses a default initial digest. But to get same HASH digest as the expected one, in these four DTHE_SHA_compute() calls, the latter one should use the result digest of the former one as its initial digest.

So, customers are asking if they can specify initial digest when calling DTHE_SHA_compute()? ex. use result digest of previous DTHE_SHA_compute() as initial digest of current DTHE_SHA_compute()

In AM263x Security Hardware Addendum, it is said "When loaded with a data block, and optionally an intermediate digest, it independently performs the hash computation (64 or 80 rounds, depending on the algorithm) on that data block." and "The engine can also start from the specified initial digest values instead of a loaded intermediate.".

Is "algorithm constants" in HASH engine designed for this kind of use case? How to use it in API level to fulfill customers' requirement?

Thanks.

  • Hi ,

    The first 256 bytes of image of each R5F core are used for HASH. Not the whole image are used for HASH because of time saving. Correspondingly, the expected HASH digest is generated on PC, where the 4 * 256 bytes (4 R5F cores, 256 bytes from image for each core) is processed continuously as a 1024 bytes data block.

    This sounds like a multi-shot example. You can use DTHE_SHA_compute(DTHE_Handle handle, DTHE_SHA_Params* ptrShaParams, int32_t isLastBlock) function as it is.

    But for the first 3 calls you must keep the 3rd parameter i.e. isLastBlock as FALSE. For the last call before closing the SHA_handle, make sure to call DTHE_SHA_compute with isLastBlock as TRUE.

    Do let me know, if you are not looking for something like this ?

    Best Regards,
    Aakash

  • Hi, Aakash,

    Thanks for the reply.

    I was assuming setting isLastBlock to FALSE may be the solution, and suggested customer to give a try. And you reply confirmed my understanding. Thanks.

    I also did below test, the result indicate it works.

    1. run DTHE_SHA_compute() with a 256 bytes data block, get digest-F

    2. run DTHE_SHA_compute() with first 64 bytes data block of the 256 bytes data block, with isLastBlock = FALSE, get digest-A

    3. run DTHE_SHA_compute() with second 64 bytes data block of the 256 bytes data block, with isLastBlock = FALSE, get digest-B

    4. run DTHE_SHA_compute() with third 64 bytes data block of the 256 bytes data block, with isLastBlock = FALSE, get digest-C

    5. run DTHE_SHA_compute() with last 64 bytes data block of the 256 bytes data block, with isLastBlock = TRUE, get digest-D

    digest-D is same as digest-F.

    I am supporting customer to get same result with customer environment, and check if this meets customer's requirement.

    Thanks. 

  • Hi Fan,

    In that case, I am considering this ticket closed.

    Thanks and Regards,
    Aakash

  • Hi, Aakash,

    Customer feedback it works with DTHE_SHA_compute(), but how about using DTHE_HMACSHA_compute(). There is not isLastBlock parameter with DTHE_HMACSHA_compute().

    Thanks,

  • Hi Fan,

    The drivers do not support HMAC in multi-shot/streaming mode. There is an existing MR already raised for the same- https://jira.itg.ti.com/browse/MCUREQ-2462.

    Best Regards,
    Aakash