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.

CC2650: Encrypt advertisement packets in hardware

Part Number: CC2650


Hi


We use the tirtos_simplelink_2_13_00_06  stack with the simpleBLEBroadcaster.c example and developed a low-power sensor application which works fine. Now we would like to encrypt our advertisement packets with the hardware AES-Modul from the CC2650.

We tried using HCI_LE_EncryptCmd(myKey, myPlainText) in the SimpleBLEBroadcaster_taskFxn() and added an event listener to the GAPRole (broadcaster.c). From there, our callback function myEncryptCb() should be called. Sadly this does not happen. Any suggestions how to proceed?

static void gapRole_processStackMsg(ICall_Hdr *pMsg)
{
  switch (pMsg->event)
  {
    case GAP_MSG_EVENT:
      gapRole_processGAPMsg((gapEventHdr_t *)pMsg);
      break;

    case HCI_SMP_EVENT_EVENT: // TODO: CAM: Added option for AES-Encryption

        if( pMsg->status == HCI_COMMAND_COMPLETE_EVENT_CODE  )
        {
          hciEvt_CmdComplete_t *pPkt = (hciEvt_CmdComplete_t *)pMsg;

          if (pPkt->cmdOpcode == HCI_LE_ENCRYPT)
          {
            extern void myEncryptCb(uint8_t, uint8_t *);
            myEncryptCb(pPkt->pReturnParam[0], &pPkt->pReturnParam[1]);
          }
        }
    break;

    default:
      break;
  }
}

Kind regards

Martin

  • Hi Martin,

    You will need to do the following in order to get the callback from the stack

    1. Add the following into the SimpleBLEBroadcaster_init function

    // Register with GAP for HCI/Host messages

     GAP_RegisterForMsgs(selfEntity);

    2. The callback will be sent back to application layer with event type = HCI_GAP_EVENT_EVENT

    That means you need to add the following call in to static void SimpleBLEBroadcaster_processStackMsg(ICall_Hdr *pMsg)

        case HCI_GAP_EVENT_EVENT: // TODO: CAM: Added option for AES-Encryption
    
            if( pMsg->status == HCI_COMMAND_COMPLETE_EVENT_CODE  )
            {
              hciEvt_CmdComplete_t *pPkt = (hciEvt_CmdComplete_t *)pMsg;
    
              if (pPkt->cmdOpcode == HCI_LE_ENCRYPT)
              {
                 asm("NOP");//whatever you want to do here
              }
            }

  • Thank you Christin for your fast reply!

    This solution does indeed work! Thanks