微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > TI蓝牙设计交流 > 关于AES加密的问题

关于AES加密的问题

时间:10-02 整理:3721RD 点击:

编译环境: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还需要其它注意事项,我没有注意到?

  请坛友帮忙,谢谢!俺也会继续测试,如有结果会及时,更新上来,谢谢!

mark,可以参考一下2541的加密与解密的使用,应该差不多

http://blog.csdn.net/feilusia/article/details/50085225

非常感谢香瓜!

2541的加密我用过,

现在主要的问题是如果加密超过16字节的数据,难道还要分包?

另外,在2640工程中,一直提示没有定义没有定义LL_Encrypt,现在还不知道是哪里加载的问题,我正在查找……

TI的大神,能出来帮忙看一下吗,谢谢!

难道大家都只是加密16个字节的,没有超过16个字节 的?

分享给后来者

《CC2640之数据加密与解密》:http://blog.csdn.net/feilusia/article/details/52389703#userconsent#

非常感谢香瓜!AES加密已搞定,多字节加密,接收发送已搞定,谢谢!

谢谢分享!

你好,

AES的加密解密TI官网有例程:

http://processors.wiki.ti.com/index.php/CC2640_AES_Encryption

另外你可以参考:

http://blog.csdn.net/feilusia/article/details/52389703#userconsent#

另外,你可以尝试把20byte字节先改小,尝试只传输10byte数据,看看编译还有没问题。

谢谢你的提示,问题已解决了,非常感谢!

请问怎么解决的?

我也需要做不定长度的数据的加解密。

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top