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.

How to use the function of TI-MAC's hal_ccm.h in my application to encrypt my user data?

I have try to add SSP_CCM_Auth_Encrypt in my application.Flowing TI-MAC's MSA example,I fill param as " TRUE, 0,  nonce, M, M-length,A,A-length,key,MAC,0". after  SSP_CCM_Auth_Encrypt finish,with M is string "0123456789ABCDEF" and M-Length is 16 and  key is "0123456789ABCDEF",the output A has not been written.

what value should A-length been written?

  uint8 status = FAILURE;
  uint8 nonce[13];
  uint8 key[16];
  uint8* m =   vcom_data + 13 + 16;
  uint16 m_len = vcom_len - (13 + 16); 
  
  osal_memcpy( nonce, vcom_data, 13 );
  osal_memcpy( key, vcom_data + 13, 16 );
  //status = SSP_CCM_Auth_Encrypt (TRUE, Mval, Nonce, M, len_m, A, len_a, AesKey, MAC, ccmLVal);
  if(aesOut == NULL)
  {
    aesOut = osal_mem_alloc( m_len + 32 );
    if( aesOut )
    {
      osal_memset( aesOut, 0, m_len + 32 );
      aesLen = m_len + 32;
      ssp_HW_KeyInit( key );
      pSspAesEncrypt = sspAesEncryptHW;
      status = SSP_CCM_Auth_Encrypt (TRUE, 0, nonce, m, m_len, aesOut + 16, 128, key, aesOut, 0 );
    }
    
  }
  return status;

  • Hey Aries,

    Can you please provide more detail to your issue?

    Here is the function doxygen:

    /******************************************************************************
     * @fn      SSP_CCM_Auth_Encrypt
     *
     * @brief   Generates CCM Authentication tag U.
     *
     * input parameters
     * @param encrypt if set to 'true' then run encryption and set to 'flase' for
     * authentication only.
     * @param   Mval    - Length of authentication field in octets [0,2,4,6,8,10,12,14 or 16]
     * @param   N       - Pointer to 13-byte Nonce
     * @param   M       - Pointer to octet string 'm'
     * @param   len_m   - Length of M[] in octets
     * @param   A       - Pointer to octet string 'a'
     * @param   len_a   - Length of A[] in octets
     * @param   AesKey  - Pointer to AES Key or Pointer to Key Expansion buffer.
     * @param   Cstate  - Pointer to output buffer
     * @param   ccmLVal - ccm L Value to be used.
     *
     * output parameters
     *
     * @param   Cstate[]    - The first Mval bytes contain Authentication Tag T
     *
     * @return  ZStatus_t
     *
     */

    ~Brocklobsta