编译环境:IAR for ARM 7.70
处理器:CC2640 7X7
TI BLE协议栈:cc26xx_2_01_01_44627
背景描述:
1、在ll.h文件中与hci.h文件中有关于AES加密的相关API,如下所示:
a) ll.h中关于AES的API函数
/*******************************************************************************
* @fn LL_Encrypt API
*
* @brief This API is called by the HCI to request the LL to encrypt the
* data in the command using the key given in the command.
*
* Note: The parameters are byte ordered MSO to LSO.
*
* input parameters
*
* @param *key - A 128 bit key to be used to calculate the
* session key.
* @param *plaintextData - A 128 bit block that is to be encrypted.
*
* output parameters
*
* @param *encryptedData - A 128 bit block that is encrypted.
*
* @param None.
*
* @return LL_STATUS_SUCCESS
*/
extern llStatus_t LL_Encrypt( uint8 *key,uint8 *plaintextData,uint8 *encryptedData ); // 加密
/*******************************************************************************
* @fn LL_EXT_Decrypt API
*
* @brief This API is called by the HCI to request the LL to decrypt the
* data in the command using the key given in the command.
*
* Note: The parameters are byte ordered MSO to LSO.
*
* input parameters
*
* @param *key - A 128 bit key to be used to calculate the
* session key.
* @param *encryptedData - A 128 bit block that is encrypted.
*
* output parameters
*
* @param *plaintextData - A 128 bit decrypted block.
*
* @param None.
*
* @return LL_STATUS_SUCCESS
*/
extern llStatus_t LL_EXT_Decrypt( uint8 *key,uint8 *encryptedData,uint8 *plaintextData ); // 解密
b) hcl.h
/*******************************************************************************
* @fn HCI_LE_EncryptCmd API
*
* @brief This LE API is used to perform an encryption using AES128.
*
* Note: Input parameters are ordered MSB..LSB.
*
* Related Events: HCI_CommandCompleteEvent
*
* input parameters
*
* @param key - Pointer to 16 byte encryption key.
* @param plainText - Pointer to 16 byte plaintext data.
*
* output parameters
*
* @param None.
*
* @return hciStatus_t
*/
extern hciStatus_t HCI_LE_EncryptCmd( uint8 *key,uint8 *plainText ); // 加密
/*******************************************************************************
* @fn HCI_EXT_DecryptCmd API
*
* @brief This HCI Extension API is used to decrypt encrypted data using
* AES128.
*
* Related Events: HCI_VendorSpecifcCommandCompleteEvent
*
* input parameters
*
* @param key - Pointer to 16 byte encryption key.
* @param encText - Pointer to 16 byte encrypted data.
*
* output parameters
*
* @param None.
*
* @return hciStatus_t
*/
extern hciStatus_t HCI_EXT_DecryptCmd( uint8 *key,uint8 *encText ); // 解密
2、根据注释可以看出,加加密的密钥为128位也即16byte,而要加密及解密的数组的长度也是16byte
问题描述:
1、那么我一包发20个字节,如果我想把这20个字节全加密,及解密,如何操作?
2、在simpleBLEPeripheral.c中测试加密解密问题,会报错:
Error[Li005]: no definition for "LL_Encrypt" [referenced from x:\ble-xx\FW\BLE_fff\Projects\ble\..
但是在simpleBLEPeripheral.c也包含了ll.h这个头文件,在包含路径中也添加了ll.h所在的文件夹:
$PROJ_DIR$/../../../../../../../Components/ble/controller/CC26xx/include
这是为什么?调用这个API还需要其它注意事项,我没有注意到?
请坛友帮忙,谢谢!俺也会继续测试,如有结果会及时,更新上来,谢谢!