Add RealTek AmebaPro2 (RTL8735B) HUK wolfCrypt example#575
Open
dgarske wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new RealTek AmebaPro2 (RTL8735B) wolfCrypt example that demonstrates using the Hardware Unique Key (HUK) via wolfCrypt CryptoCb, intended to be built inside the RealTek FreeRTOS SDK.
Changes:
- Introduces an AmebaPro2 HUK AES example app (GCM/ECB/CBC/CTR) that registers the HUK crypto-callback device and runs known-answer/round-trip checks.
- Adds a minimal
user_settings.hconfiguration for a wolfCrypt-only, AES-focused build in the SDK. - Adds CMake wiring (
wolfcrypt_huk.cmake) and README instructions for integrating the example into the RealTek SDK build.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| AmebaPro2/main.c | New FreeRTOS task example exercising AES modes via the HUK crypto-callback device. |
| AmebaPro2/user_settings.h | New wolfCrypt configuration for the example (CryptoCb + AES modes + HashDRBG seed hook). |
| AmebaPro2/wolfcrypt_huk.cmake | New SDK build “wiring” to add wolfCrypt sources, include paths, and defines. |
| AmebaPro2/README.md | New integration/build/flash documentation for the AmebaPro2 HUK example. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+87
to
+91
| seed[0] ^= 0xFF; | ||
| wc_AesGcmSetKey(&aes, seed, sizeof(seed)); | ||
| ret = wc_AesGcmDecrypt(&aes, dec, ct, sizeof(ct), iv, sizeof(iv), | ||
| tag, sizeof(tag), aad, sizeof(aad)); | ||
| CHECK("wrong seed -> AES_GCM_AUTH_E", ret == AES_GCM_AUTH_E); |
Comment on lines
+108
to
+111
| dbg_printf("\r\n== AES-ECB under HUK-derived key ==\r\n"); | ||
| wc_AesInit(&aes, NULL, WC_HUK_DEVID); | ||
| ret = wc_AesSetKey(&aes, seed, sizeof(seed), NULL, AES_ENCRYPTION); | ||
| CHECK("AesSetKey(ECB enc)", ret == 0); |
Comment on lines
+119
to
+122
| dbg_printf("\r\n== AES-CBC under HUK-derived key ==\r\n"); | ||
| wc_AesInit(&aes, NULL, WC_HUK_DEVID); | ||
| ret = wc_AesSetKey(&aes, seed, sizeof(seed), iv, AES_ENCRYPTION); | ||
| CHECK("AesSetKey(CBC enc)", ret == 0); |
Comment on lines
+144
to
+147
| dbg_printf("\r\n== AES-CTR under HUK-derived key ==\r\n"); | ||
| wc_AesInit(&aes, NULL, WC_HUK_DEVID); | ||
| ret = wc_AesSetKeyDirect(&aes, seed, sizeof(seed), iv, AES_ENCRYPTION); | ||
| CHECK("AesSetKeyDirect(CTR)", ret == 0); |
Comment on lines
+153
to
+156
| /* CTR is its own inverse with the same key+IV */ | ||
| wc_AesInit(&aes, NULL, WC_HUK_DEVID); | ||
| wc_AesSetKeyDirect(&aes, seed, sizeof(seed), iv, AES_ENCRYPTION); | ||
| ret = wc_AesCtrEncrypt(&aes, dec, ct, sizeof(ct)); |
Comment on lines
+179
to
+182
| dbg_printf("\r\n== AES-GCM with UNALIGNED buffers (port bounces) ==\r\n"); | ||
| wc_AesInit(&aes, NULL, WC_HUK_DEVID); | ||
| ret = wc_AesGcmSetKey(&aes, seed, 32); | ||
| CHECK("AesGcmSetKey (unaligned seed)", ret == 0); |
| ## Prerequisites | ||
|
|
||
| - RealTek AmebaPro2 FreeRTOS SDK: https://github.com/Ameba-AIoT/ameba-rtos-pro2 | ||
| - RealTek ASDK 10.3.0 toolchain (GCC 10.3.0): https://github.com/Ameba-AIoT/ameba-toolchain (tag `V10.3.0-amebe-rtos-pro2`). The stock system `arm-none-eabi-gcc` does not build the SDK (newlib/lwip header clashes); use the ASDK toolchain. |
| set(WOLFSSL_ROOT ${CMAKE_CURRENT_LIST_DIR}/../../../../wolfssl) | ||
| endif() | ||
| endif() | ||
| if(NOT EXISTS ${WOLFSSL_ROOT}/wolfcrypt/src/aes.c) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
wolfSSL/wolfssl#10677