主题中讨论的其他器件: SysConfig
工具与软件:
您好!
以下是我的软件和硬件版本:
LP-EM-CC2745R10-Q1
simplelink_lowpower_f3_sdk_8_40_00_61
CCS 版本:20.0.2.5__1.6.2
我根据 examples\rtos\LP_EM_CC2745R10_Q1\ble5stack\basic_ble 例程测试了 f3 SDK 中的 HSM 功能、并测试了 AES-CBC/AES-GCM 可以正常工作。 但当我添加 ECDH 测试时,我一直得到 ECDH_OPEN()返回 NULL。 我曾尝试在论坛上查找相关问题、并进行了一些修改、例如添加预定义符号"DeviceFamily_CC27XX"和"USE_HSM"、但这些仍然没有解决。 您能不能帮我看看导致出现这种现象的原因是什么?
这是我的函数、我删除了线程中的函数、然后刚刚运行我自己的测试函数
static const char ecdh_msg[] = "\n\n\rECDH Open fail"; static void ECDH_Test(void) { ECDH_Handle ecdhHandle; ECDH_Params ecdhParams; CryptoKey myPrivateKey; CryptoKey myPublicKey; CryptoKey theirPublicKey; CryptoKey theirPrivateKey; CryptoKey mysharedSecret; CryptoKey theirsharedSecret; CryptoKey symmetricKey; int_fast16_t operationResult; ECDH_OperationGeneratePublicKey operationGeneratePublicKey; ECDH_OperationComputeSharedSecret operationComputeSharedSecret; ECDH_init(); ECDH_Params_init(&ecdhParams); ecdhParams.returnBehavior = ECDH_RETURN_BEHAVIOR_BLOCKING; ecdhHandle = ECDH_open(CONFIG_ECDH0, &ecdhParams); if (!ecdhHandle) { printMessage(uart, (char *)ecdh_msg, NULL, 0); while(1); } // CryptoKeyPlaintextHSM_initKey(&myPrivateKey, myPrivateKeyingMaterial, sizeof(myPrivateKeyingMaterial)); // CryptoKeyPlaintextHSM_initBlankKey(&myPublicKey, myPublicKeyingMaterial, sizeof(myPublicKeyingMaterial)); // ECDH_OperationGeneratePublicKey_init(&operationGeneratePublicKey); // operationGeneratePublicKey.curve = &ECCParams_Curve25519; // operationGeneratePublicKey.myPrivateKey = &myPrivateKey; // operationGeneratePublicKey.myPublicKey = &myPublicKey; // // If generating public key in little-endian format, we use the following format: // operationGeneratePublicKey.keyMaterialEndianness = ECDH_LITTLE_ENDIAN_KEY; // //generate my pub-key // operationResult = ECDH_generatePublicKey(ecdhHandle, &operationGeneratePublicKey); // if (operationResult != ECDH_STATUS_SUCCESS) // { // printMessage(uart, (char *)ecdh_msg2, NULL, 0); // // Handle error // } // printMessage(uart, (char *)promptClearText, (char *)myPublicKeyingMaterial, sizeof(myPublicKeyingMaterial)); // printBanner(uart, (char *)"*"); } void App_StackInitDoneHandler(gapDeviceInitDoneEvent_t *deviceInitDoneData) { bStatus_t status = SUCCESS; GPIO_init(); GPIO_setConfig(CONFIG_GPIO_LED_GREEN, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW); GPIO_setConfig(CONFIG_GPIO_LED_RED, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW); GPIO_write( CONFIG_GPIO_LED_GREEN, CONFIG_LED_ON ); GPIO_write( CONFIG_GPIO_LED_RED, CONFIG_LED_ON ); UART2_Params_init(&uartParams); uartParams.baudRate = 115200; uart = UART2_open(CONFIG_UART2_0, &uartParams); if (uart == NULL) { /* UART2_open() failed */ while (1) {} } char array[] = "example start !! \r\n"; printClearText(uart,array,NULL,0); // AES_CBC_Test(); // AES_GCM_Test(); ECDH_Test(); }