微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > TI无线射频设计 > CC1310的AES每次只能加密16个字节吗?

CC1310的AES每次只能加密16个字节吗?

时间:12-23 整理:3721RD 点击:

CC1310的AES每次只能加密16个字节吗?我测试一下aes程序,发现只能16直接才正确,不能一次加密多个字节的数据吗?

void testAes()
{
    // Enable the AES module
    Power_setDependency(PowerCC26XX_PERIPH_CRYPTO);
    // 禁止待机 , 加密的时候才需要这个代码,加密结束之后,释放,允许进入待机就可以了
    Power_setConstraint(PowerCC26XX_SB_DISALLOW);

    uint8_t i;

    // 设置变量,也就是加密代码
    uint8_t aesKey[16] = {0x5a, 0x69, 0x67, 0x42, 0x65, 0x65, 0x41, 0x6c, 0x6c, 0x69, 0x61, 0x6e, 0x63, 0x65, 0x30, 0x39};

    uint8_t inputData[20] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F};

    uint8_t encryptedData[sizeof(inputData)] = { 0 };
    uint8_t outputData[sizeof(inputData)] = { 0 };

    enum
    {
        Encrypt             = 0x01,
        Decrypt             = 0x00,
        InterruptsEnabled   = 0x01,
        InterruptsDisabled  = 0x00,
    };



    //密码硬件最多可存储8个密钥。
    //对于128位密钥,所有8个从0到8的关键区域都有效
    //但是对于192位和256位键,只有键区0,2,4,6有效。

    uint8_t keyIndex = CRYPTO_KEY_AREA_3;

    // Load the key to the crypto unit
    CRYPTOAesLoadKey((uint32_t*)aesKey, keyIndex);


    // 以阻塞模式进行加密
    CRYPTOAesEcb((uint32_t*)inputData, (uint32_t*)encryptedData, keyIndex, Encrypt, InterruptsDisabled);
    while (CRYPTOAesEcbStatus() != AES_SUCCESS);



    // 再次以阻塞模式解密数据
    CRYPTOAesEcb((uint32_t*)encryptedData, (uint32_t*)outputData, keyIndex, Decrypt, InterruptsDisabled);
    while (CRYPTOAesEcbStatus() != AES_SUCCESS);


    // Allow standby and release the crypto module.
    Power_releaseConstraint(PowerCC26XX_SB_DISALLOW);
    Power_releaseDependency(PowerCC26XX_PERIPH_CRYPTO);
}

另外程序正常运行的时候没问题,但是我把这个程序拆开的时候,单独运行解密的时候,挂掉了。程序卡主了,这个是什么情况呢?能指教一下吗?

论坛有类似问题,解答请看这边: https://e2e.ti.com/support/wireless_connectivity/bluetooth_low_energy/f/538/t/543394  【AES功能类似】

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

网站地图

Top