In cc310 SaSi_AesBlock isn't returning from the function call

Hello there,

I want to use the CC310 module for encryption.

I uploaded an example(i.e. \nRF5_SDK_17.1.0_ddde560\examples\crypto\nrf_cc310\aes) from the SDK to my nrf 52840 dev kit and in the debug I see that all tests are going well and the module is working. But when I wanted to add encryption to my project which has ble using NUS profile, then I ran into problems. I wanted to use AES in ECB mode. The module initialization functions SaSi_AesInit,  SaSi_AesSetKey from example pass successfully and output is SA_SILIB_RET_OK. But when I want to use SaSi_AesBlock for encryption i see the data being  encyrpted but the function is not returning SA_SILIB_RET_OK, it is getting struck inside it and isn't coming out of the function. Is there anything i need to enable in sdk_config file.

Can anyone please help me in solving the issue.

Regards,

Shafi

Parents
  • Hi Shafi, 

    I'm not an expert in crypto and encryption but let see if I can help here. 
    The nRF52840 has AES ECB module on the hardware (as far as I know it's independent from the CC310) that you can consider to use. 
    When the softdevice is active you can use sd_ecb_blocks_encrypt() to do the encryption. There is a blog about that here.

    Regarding your issue with SaSi_AesBlock() have you tried to disable softdevice and run the AES code again. If it works, it must be something to do with softdevice and CC310 running together. 
    Could you let me know where you call the SaSi functions? Is it in main context or in an interrupt handler ?

    Have you double check if you don't have a hardfault ? If you do , you can have a look at this similar case and check if you have any log. 
    It's suggested that you use nrf_crypto to access CC310 instead of using CC310 directly. Please check out nrf_crypto examples. 


  • Hi Hang,

    First of all thank you for the response

    I will try to disable the softdevice and  try, Can you please tell me how to disable it.

    I calling the SaSi_AesBlock() in main function not interrupt handler.

    It is not hitting the hardfault.

    Can you also specify which example to use in nrf_crypto for ECB mode.

    Regards,

    Shafi

  • Hi Shafi, 

    I don't see any reason the code in the blog shouldn't work with NRF52832. Please try to implement it.

    shafi said:
    I tried disabling softdevice, but it isn't working.

    Are you saying that without the softdevice initialized you also don't have it working ? So what's the difference between the example (that works) and your application ? 

    Anyway, if you can follow the blog to make it work with nRF52840 I don't see much point using CC310 in this case. 

  • Hi Hung,

    I have implement encryption using sd_ecb_block_encrypt it is working for me, how to decrypt the cipher text? 

    crypt function is not utilizing buf it is just xor with the cipher text.
    Can you please help me in decrypting the data

    Does enabling softdevice disable use of AES functionality?

    Regards,

    Shafi  

  • Hi Hung,

    Can you please answer to the above question?

    Regards,

    Shafi

  • Hi Shafi, 
    Have you gone through the blog ? 
    In the blog Daniel explained how the same function can do both encrypt and decrypt if you use it as stream cipher (counter mode). 

    At the end, before the Conculsion you can find the code to encrypt and decrypt. 

    When the softdevice is active AES is not blocked. It's only restricted so that you need to use softdevice API to access it (sd_ecb_block_encrypt) instead of accessing the hardware directly. 

  • should i increment index 3 of counter or the index 0 in [nounce|ctr]

Reply Children
Related