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.

AM263P4: Program issues related to the SHA module of AM263P4 hardware

Part Number: AM263P4
Other Parts Discussed in Thread: SHA-256

I reviewed the SHA calculation program for the DTHE module in the AM263P4 SDK (mcu_plus_sdk_am263px_11_00_00_19). When it is not the last block of data, for SHA256, the input length of the original text must be a multiple of 64 bytes. According to the program logic, for non-SHA256 algorithms, such as SHA1, SHA224, SHA384, SHA512, and MD5, the input length of the original text must be a multiple of 128 bytes.

The first question: does this indicate that the program only considers the cases of SHA256 and SHA512 (since only DTHE_SHA256_BLOCK_SIZE and DTHE_SHA512_BLOCK_SIZE are listed, and the comment states /* Sanity Checking: Any data buffer except the last block should be aligned as per the SHA Size. For SHA256 this is 64byte while for SHA512 this should be 128byte */), without accounting for other cases, or is the program designed to simply distinguish between SHA256 and non-SHA256?

The second question: for the last block of data, regardless of the algorithm, is there no requirement on the input length?

image.png

  • Hi mingzhe,

    Let me sync up internally on this and get back to you.

    Thanks and Regards,
    Aditya Singal

  • Hi ,

    dthe_sha.c is only validated to be tested with SHA2-256, SHA2-384 and SHA2-512. For all the mentioned intermediate block size must be equal to size of the input. This is how the hardware is designed to work as the processing of the block is only done when the IP receives the block sized data. In case if you have data smaller than the block size, you can handle them at application wrapper.

    Do you have requirements for other SHA option like SHA1 ? We don't support them as the SHA1 has been depreciated due to increase in collision prediction.

    Best Regards,
    Aakash

  • Then do you mean that the current DTHE only supports SHA2-256, SHA2-384, and SHA2-512, and does not support algorithms like MD5 and SHA1? Also, for SHA2-256, the non-final block requires 64-byte alignment, while for SHA2-384 and SHA2-512, the non-final block requires 128-byte alignment. Is that correct?

    Then why does the text below state that it supports MD5, SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512?

  • Hi ,

    Also, for SHA2-256, the non-final block requires 64-byte alignment, while for SHA2-384 and SHA2-512, the non-final block requires 128-byte alignment. Is that correct?

    Yes that is correct and as per the SHA specification.

    Then why does the text below state that it supports MD5, SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512?

    It is mentioned above that these are supported in hardware but not yet in software.

    Thanks and Regards,
    Aditya Singal