Bare meta example of SHA256 in i.MX6

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Bare meta example of SHA256 in i.MX6

907 Views
cyrilledebrebis
Contributor I

Hello,

I am looking for some code that will show how to use the i.MX6 Data Co Processor to calculate a SHA256.

I tried the following:

  CCM->CCGR0|= CCM_CCGR0_CG5(3);                  // turn on GPIO4
  L1C_CleanInvalidateDataCacheRange((void*)data, len);
  L1C_CleanInvalidateDataCacheRange((void*)hash, 256/8);
  memset(&dcp1, 0, sizeof(dcp1));
  // set up control packet
  dcp1.next = 0; // single packet in chain
  dcp1.ctrl0.HASH_INIT = 1; // initialize hash with this block
  dcp1.ctrl0.HASH_TERM = 1; // terminate hash with this block
  dcp1.ctrl0.ENABLE_HASH = 1; // enable hash
  dcp1.ctrl0.DECR_SEMAPHORE = 1; // decrement semaphore
  dcp1.ctrl1.HASH_SELECT= 2; // sha256.
  dcp1.src = data; // source buffer
  dcp1.buf_size = len; // 512 bytes
  dcp1.payload = hash; // holds expected hash value
  // Enable channel 0
  DCP->CHANNELCTRL= 0x101; // enable channel 0
  DCP->CH0CMDPTR= (u32)&dcp1;
  DCP->CH0SEMA= 1;
  mydcpcp= DCP;
  // now wait for interrupt or poll
 while ( (DCP->CH0SEMA & 0xff0000) != 0x00 );

But, Althrough it does calculate something, it does not seem to match other sha256 calcuators.

Anything that I am imssing?

cyrille

Labels (1)
0 Kudos
1 Reply

750 Views
igorpadykov
NXP Employee
NXP Employee

Hi Cyrille

what processor used in the case, for example for i.MX6DQ/SDL

some caam baremetal examples can be found in sdk:

Github SDK
https://github.com/backenklee/swp-report/tree/master/iMX6_Platform_SDK

For sha256 example one can look at linux caam driver described in attached Linux Manual

sect.8.1 Cryptographic Acceleration and Assurance Module (CAAM).

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos