AnsweredAssumed Answered

SHA-256 with mmCAU in K64

Question asked by Mark Butcher on Oct 10, 2018
Latest reply on Oct 17, 2018 by Mark Butcher

Hi All

 

I have been using SHA256 in mbedTLS and wanted to improve its speed by making use of the mmCAU in the K64.

 

Using the M4 assember code supplied [mmcau_sha256_functions.s] and the calls according to https://www.nxp.com/docs/en/user-guide/CAUAPIUG.pdf I haven't yet been able to get correct output.

 

Taking a simple test case of a 64 byte input block of "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"

the known result is
FFE054FE7AE0CB6DC65C3AF9B61D5209F439851DB43D0BA5997337DF154668EB

 

but I get always

0x45 0xea 0x6b 0xd6 0x74 0x80 0x39 0xe8 0x86 0xcd 0xc4 0x4e 0xa9 0x64 0x55 0x02 0x7e 0xe5 0xcc 0x61 0xeb 0x5e 0x61 0x0a 0x97 0xa4 0x42 0x7e 0x66 0x93 0x7a 0x9e

 

using either of thee methods:

 

mmcau_sha256_initialize_output((const unsigned int *)sha256.state);
mmcau_sha256_hash((const unsigned char *)sha256.buffer, (unsigned int *)sha256.state);

 

or
mmcau_sha256_initialize_output((const unsigned int *)sha256.state);
mmcau_sha256_hash_n((const unsigned char *)sha256.buffer, (const int)1, (unsigned int *)sha256.state);

 

or

 

mmcau_sha256_update((const unsigned char *)sha256.buffer, (const int)1, (unsigned int *)sha256.state);

 

In the third case mmcau_sha256_initialize_output() is not needed beforehand.

 

 

All buffers are aligned and the single block case (no padding) with repeated data should avoid any possible problems with preparing data correctly (like endian-ness).

 

Looking at the mmcau_api in the SDK reference it tests the speed of the operation but not the actual result.

 

Anyone see a reason why the library functions wouldn't return good values?

 

Regards

 

Mark

Outcomes