This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Memory Corruption when Using CryptoCell310's AES CCM Module

Hello,

I am developing a driver that can handle cryptographic operations and I am using example code from nRF5_SDK_16.0.0_98a08e2/examples/crypto/nrf_cc310/aes to get started with encryption using AES-CCM. While developing my driver, I came across a strange phenomenon where when calling CRYS_AESCCM(), some of my input buffers are being overwritten to zero after the function executes. Additionally, the first 4 bytes of my output buffer (i.e. the ciphertext buffer) are being set to zero but the remaining bytes of the buffer are set to the correct expected output. Note that the CRYS_AESCCM() call returns no errors.

I am using IAR 8.40.2 and the CC310 Crypto library I'm using is located at nRF5_SDK_16.0.0_98a08e2/external/nrf_cc310/lib/cortex-m4/hard-float/libnrf_cc310_0.9.12.a. I first thought that there was something wrong with my project settings, so I switched to the example aes project and noticed that I get similar results when I reduce the size of the nonce buffer to 16 bytes (inside of aes_ccm_tests() of main.c), though only 7 bytes should be needed because the test vector nonce being used is only 7 bytes long. I found that if the nonce buffer size is 16 bytes or less, it gets overwritten to all zeros after calling CRYS_AESCCM(). However, if the nonce buffer is 17 bytes or more, the buffer remains intact after calling CRYS_AESCCM(). So in summary, I have two questions:

  1. Are there some minimum buffer size requirements that I need to keep in mind when calling CRYS_AESCCM?
  2. If I am using the S140 soft device to run BLE functionality, is it ok if i make calls to the Cryptocell310 module?

Thanks,

Keron

Parents
  • Hi,

    1. This could maybe be related to the comment in components\libraries\crypto\backend\cc310\cc310_backend_aes_aead.c:

    /* CC310 backend always needs 16 bytes buffer for MAC calculation. */

    In general, the CC310 API is quite hard to use, and there is not much checking if things are done correctly. We rather recommend using the nrf_crypto library, with the CC310 backend. This should do a lot more checking, to make sure every parameter and placement is valid.

    2. There should not be any problems with using the CC310 together with the softdevice.

    Best regards,
    Jørgen

Reply
  • Hi,

    1. This could maybe be related to the comment in components\libraries\crypto\backend\cc310\cc310_backend_aes_aead.c:

    /* CC310 backend always needs 16 bytes buffer for MAC calculation. */

    In general, the CC310 API is quite hard to use, and there is not much checking if things are done correctly. We rather recommend using the nrf_crypto library, with the CC310 backend. This should do a lot more checking, to make sure every parameter and placement is valid.

    2. There should not be any problems with using the CC310 together with the softdevice.

    Best regards,
    Jørgen

Children
Related