如题,CC2640R2F AES 128bit CBC 加密出来的数据和APP、服务器加密出来的数据不同。下面是我的实际代码,请问代码有什么问题?
uint8_t AES_encryptionByCBC(uint8_t *key, uint8_t *dataIn, uint8_t *dataOut) {// Declaration (typically done in a task)CryptoCC26XX_Handlehandle;int32_tkeyIndex;int32_tstatus;CryptoCC26XX_AESCBC_Transaction trans;// Initialize Crypto driverCryptoCC26XX_init();// Attempt to open CryptoCC26XX.handle = CryptoCC26XX_open(CC2640R2_LAUNCHXL_CRYPTO0, false, NULL);if (!handle) {return FAILURE;}keyIndex = CryptoCC26XX_allocateKey(handle, CRYPTOCC26XX_KEY_ANY, (const uint32_t *) key);if (keyIndex == CRYPTOCC26XX_STATUS_ERROR) {return FAILURE;}// Initialize transactionCryptoCC26XX_Transac_init((CryptoCC26XX_Transaction *) &trans, CRYPTOCC26XX_OP_AES_CBC_ENCRYPT);// Setup transactiontrans.keyIndex = keyIndex; //trans.nonce= key;trans.msgIn= (uint32_t *) dataIn;trans.msgOut= (uint32_t *) dataOut;trans.msgInLength = 16;// Encryptstatus = CryptoCC26XX_transact(handle, (CryptoCC26XX_Transaction *) &trans);if(status != CRYPTOCC26XX_STATUS_SUCCESS){return FAILURE;}CryptoCC26XX_releaseKey(handle, &keyIndex);//CryptoCC26XX_close(handle);return SUCCESS; }
Viki Shi:
CC26XX的AES加密请参考http://processors.wiki.ti.com/index.php/CC2640_AES_Encryption 以及TI RTOS的相关文档
user5112262:
回复 he:
你好 请问你的这个问题解决了吗?
he:
回复 user5112262:
解决了啊,参考上面的代码。
user5112262:
回复 he:
感谢!我刚好使用这个,但安照wiki上的方法CC2640R2F蓝牙crash。直接引用头文件#include <ti/drivers/crypto/CryptoCC26XX.h>就可以了吧?
he:
回复 user5112262:
是的
user5112262:
回复 he:
大神你好,再问个问题改自带加密引擎AES-CBC接口的填充方式是什么。需要在外部实现还是内部支持可配啊?