你好支持!
The code as shown in documentation does not work.
uint8_t txt[] = "what do ya want for nothing?" uint8_t key[] = "Jefe" uint8_t hmac[32]; crypto_hmac_ctx_t hmac_status = crypto_hmac_sha256(txt, 28, key, 4, hmac, CRYPTO_HMAC_NO_OPTION, 100); if (hmac_status == -1) { // Failed to acquire the AES/HASH engine within 100 ticks } else { // Everything is fine }
Execution stops on line 64 in crypto_hmac.c at ad_crypto_acquire_aes_hash(timeout).
crypto_hmac_ctx_t crypto_hmac_sha256(const uint8_t * text,size_t text_sz,const uint8_t * key,size_t key_sz,uint8_t * hmac,unsigned int标志,os_tick_time超时){int i;uint8_t k0 [crypto_hmac_sha256_block_sz];uint8_t h_k0_ipad [crypto_hmac_sha256_block_sz];uint8_t * h_k0_opad = null;if(ad_crypto_acquire_aes_hash(超时)!= os_mutex_taken){return -1;} / *启用引擎时钟和适配器事件处理* / ad_crypto_enable_aes_hash_event();
我找不到任何其他tha代码示例t show the right usage and I ask you to help me. I very much appreciate if you could show me how to calculate a SHA256 resp. HMAC.
我也试图解决它是由某些不同的预先执行的
hw_aes_hash_init(&s); // s : hw_aes_hash_setup
但到目前为止没有运气。
Thank you,
Thomas
设备:
托马斯,
Thanks for your question on our public Bluetooth forums. I have followed the Doxygen SDK files in order to use the crypto_hmac library, but I am not able to reproduce the issue that you mentioned. I’ve tested in both non-BLE (freertos_retarger) and BLE (ble_peripheral) SDK examples. Please make sure that you are following the correct steps. Attached you will find some screenshots for your convenience.
A] HW/SW Setup
- 使用带DA14683子板的DA1468X Pro-DK
- da1468x_da15xxx_sdk_1.0.14.1081
- 使用BLE_PERITITAL,该项目\ DK_APPS \特征\ BLE_PERICATELAL SDK路径
b]导入Crypto_hmac库
1.Open the SmartSnippets Studio (SSS) and import the ble_peripheral. I would recommend using a clean SDK install or delete the .metadata from the existing one.
2.从“Project Explorer”窗口中展开BLE_Peripheral文件夹,然后右键单击到BLE_PERITELAL \ SDK。在此文件夹下添加一个新子文件夹。请参阅b_1.png照片。
3. In the pop-up window expand the advanced option. Please refer to B_2.png. You should add the crypto SDK folder as linked resources.
4.项目树应该像b_3.png,应该添加加密驱动程序。
5. Right-click in the ble_peripheral from the “Project Explorer” window and go to the “Properties”
6. The crypto driver might be set in absolute path location (B_6.png)
7.将路径位置更改为b_7.png
8. Add the crypto driver in the includes as shown in B_8_i.png, B_8_ii.png and B_8_iii.png
C] SW修改
1. Include the crypto_hmac.h into ble_peripheral_task.c
2. In custom_config_qspi.h :
3. In the ble_peripheral_task before the for(;;) loop add the following code snippet.
4. Build the project for DA14683-00-Debug-QSPI configuration.
5. Initiate a debug session and the add a break point into the “Succeeded”
6.应命中断点,应成功执行Crypto_hmac_sha256()。
Please follow the procedure described and let me know with your feedback.
Thanks, PM_Dialog
嗨pm_dialog,
您是完美的权利,它的工作方式如上所述和预期。最后它在我的应用程序中工作。哪里错了?
I do some AES-256 decryption before hmac calculation anddid notcallhw_aes_hash_disable_clock();然后。这导致了崩溃。添加此函数后,调用Everthing工作正常。
我唯一不确定的是,如果我的参数设置是对的,如果hw_aes_hash ...()函数的顺序也可以吗?
谢谢!
Thomas
托马斯,
Glad it is working and thank you for accepting my answer. I saw that you created a new forum thread (link is provided below). I will respond you in the new one.
https://support.dialog-semiconductor.com/forums/post/dialog-smartbond-bluetooth-low-energy-%E2%80%93-software/aes-cbc-no-padding
Thanks, PM_Dialog