ESP32S3 crash

nandishre
Posts: 5
Joined: Tue Apr 16, 2024 8:12 am

ESP32S3 crash

Postby nandishre » Fri Aug 15, 2025 10:51 am

void dps_sas_authenticationKey_blob_final(const uint8_t *decrypted_data, size_t data_len)
{
ESP_LOGI(TAG, "🔐 Generating complete SAS token from TPM authentication key blob");

// Extract symmetric key
uint8_t symmetric_key[64];
size_t key_len = 64;
if (extract_symmetric_key_from_tpm_data(decrypted_data, data_len, symmetric_key, &key_len) != ESP_OK)
{
ESP_LOGE(TAG, "Failed to extract symmetric key from TPM data");
}

time_t now = time(NULL);
time_t expiry = now + 3600;
ESP_LOGI(TAG, "Current time: %ld, Expiry time: %ld", (long)now, (long)expiry);

// Build resource and the string-to-sign
char resource_uri[256] = {0};
sprintf(resource_uri, "%s/registrations/%s", DPS_ID_SCOPE, DPS_REGISTRATION_ID);
char encoded_resource[512] = {0};
url_encode(resource_uri, encoded_resource, sizeof(encoded_resource));

char string_to_sign[768] = {0};
size_t string_to_sign_length = snprintf(string_to_sign, sizeof(string_to_sign), "%s\n%ld", encoded_resource, (long)expiry);

ESP_LOGI(TAG, "🔑 Signing string: %s %d", string_to_sign, string_to_sign_length);

uint8_t hmac_result[32];
Hmac hmac;

printf("Key length: %d bytes\n", key_len); /* Validate inputs and fix corrupted buffer size */
int ret = wc_HmacInit(&hmac, NULL, INVALID_DEVID);
if (ret != 0)
{
printf("wc_HmacInit failed: %d\n", ret);
}
uint8_t safe_key[64]; // max HMAC block size for SHA256
if (key_len > sizeof(safe_key))
{
printf("Key length too big: %u\n", (unsigned)key_len);
}
memcpy(safe_key, symmetric_key, key_len);
ret = wc_HmacSetKey(&hmac, WC_SHA256, safe_key, (word32)key_len);
if (ret != 0)
{
printf("wc_HmacSetKey failed: %d\n", ret);
wc_HmacFree(&hmac);
}
ret = wc_HmacUpdate(&hmac, (const byte *)string_to_sign, (word32)string_to_sign_length);
if (ret != 0)
{
printf("wc_HmacUpdate failed: %d\n", ret);
wc_HmacFree(&hmac);
}
ret = wc_HmacFinal(&hmac, hmac_result);
if (ret != 0)
{
printf("wc_HmacFinal failed: %d\n", ret);
wc_HmacFree(&hmac);
}
// wc_HmacFree(&hmac);
printf("HMAC calculation successful\n"); /* Debug: Print HMAC result */
unsigned char signature_b64[128] = {0};
// memset(temp_b64_buffer, 0, 128);
size_t encoded_len = 0;
// ESP_LOGI(TAG, "About to encode %d bytes to Base64 using mbedtls", sizeof(hmac_result));

int mbedtls_ret = mbedtls_base64_encode(signature_b64, 127, &encoded_len, hmac_result, sizeof(hmac_result));

// ESP_LOGI(TAG, "mbedtls_base64_encode returned: %d, encoded_len: %d", mbedtls_ret, encoded_len);
if (mbedtls_ret != 0)
{
printf("mbedtls_base64_encode failed: %d\n", mbedtls_ret);
}
signature_b64[encoded_len] = '\0';
printf("Base64 result starts length %d \n", encoded_len); /* Copy to output buffer with safety checks */

printf("\r\nGenerated Base64 signature: %s\n", signature_b64);
}
Guru Meditation Error: Core 0 panic'ed (Double exception). Core 0 register dump: PC : 0x403840c2 PS : 0x00040b36 A0 : 0x8200d97e A1 : 0x3fcaeec0 --- 0x403840c2: _xt_context_save at C:/Espressif/frameworks/esp-idf-v5.4.2/components/xtensa/xtensa_context.S:203 A2 : 0xffffffff A3 : 0x3fcaf080 A4 : 0x00000000 A5 : 0x00000000 A6 : 0x00000000 A7 : 0x3c055e28 A8 : 0x8200d3f5 A9 : 0x3fcaee70 A10 : 0x00000001 A11 : 0x3c055e28 A12 : 0x3c057458 A13 : 0x00003fe3 A14 : 0x3c055e28 A15 : 0x0000002c SAR : 0x00000004 EXCCAUSE: 0x00000002 EXCVADDR: 0x00003fd3 LBEG : 0x400556d5 LEND : 0x400556e5 LCOUNT : 0xfffffffd --- 0x400556d5: strlen in ROM --- 0x400556e5: strlen in ROM Backtrace: 0x403840bf:0x3fcaeec0 0x4200d97b:0x3fcaf070 0x4200d97b:0x00000000 |<-CORRUPTED --- 0x403840bf: _xt_context_save at C:/Espressif/frameworks/esp-idf-v5.4.2/components/xtensa/xtensa_context.S:202 --- 0x4200d97b: process_azure_challenge at F:/Fubeus/fubesu_hydroconnect/HYDRA_CONNECT_nandy/main/tpm_io_espressif.c:2751 --- 0x4200d97b: process_azure_challenge at F:/Fubeus/fubesu_hydroconnect/HYDRA_CONNECT_nandy/main/tpm_io_espressif.c:2751

another logs : Guru Meditation Error: Core 0 panic'ed (Unhandled debug exception).
Guru Meditation Error: Core 0 panic'ed (Double exception).

Core 0 register dump:
PC : 0x40384646 PS : 0x00040c36 A0 : 0x00000000 A1 : 0x3fcb2af0
--- 0x40384646: _xt_context_save at C:/Espressif/frameworks/esp-idf-v5.4.2/components/xtensa/xtensa_context.S:203
A2 : 0x00040c36 A3 : 0x00040026 A4 : 0x00000001 A5 : 0x3fcb2c04
A6 : 0x00000000 A7 : 0x3fcb2be0 A8 : 0x3fcb2bb0 A9 : 0x00000004
A10 : 0x3fcb2c50 A11 : 0x3fcb2be0 A12 : 0x3fcb20b0 A13 : 0x3fcb2100
A14 : 0x3fc9d370 A15 : 0x00000008 SAR : 0x0000000c EXCCAUSE: 0x00000002
EXCVADDR: 0x00000004 LBEG : 0x400570e8 LEND : 0x400570f3 LCOUNT : 0xffffffff
--- 0x400570e8: memset in ROM
--- 0x400570f3: memset in ROM


Backtrace: 0x40384643:0x3fcb2af0
--- 0x40384643: _xt_context_save at C:/Espressif/frameworks/esp-idf-v5.4.2/components/xtensa/xtensa_context.S:202

Guru Meditation Error: Core 0 panic'ed (Unhandled debug exception).
Debug exception reason: BREAK instr
Core 0 register dump:
PC : 0x403743c0 PS : 0x00060436 A0 : 0x8200a4e9 A1 : 0x3fcb2fb0
--- 0x403743c0: _DoubleExceptionVector at C:/Espressif/frameworks/esp-idf-v5.1.6/components/freertos/FreeRTOS-Kernel/portable/xtensa/xtensa_vectors.S:564
A2 : 0x3c056d64 A3 : 0x3fcb35b0 A4 : 0x3fc9c86c A5 : 0x00000000
A6 : 0x00000000 A7 : 0x00000000 A8 : 0x8200b616 A9 : 0x3fcb2740
A10 : 0x3fcb2f38 A11 : 0x00000000 A12 : 0x3fcb2750 A13 : 0x0000002d
A14 : 0x00000e1e A15 : 0x00000100 SAR : 0x00000004 EXCCAUSE: 0x00000001
EXCVADDR: 0xffffffe0 LBEG : 0x400556d5 LEND : 0x400556e5 LCOUNT : 0xfffffff4
--- 0x400556d5: strlen in ROM
--- 0x400556e5: strlen in ROM


Backtrace: 0x403743bd:0x3fcb2fb0 0x4200a4e6:0x00000000 |<-CORRUPTED
--- 0x403743bd: _UserExceptionVector at ??:?
--- 0x4200a4e6: tpmTask at F:/Fub/fubconnect/HYNECT_CLAUD/main/hyconnect_main.c:377


in this code we are getting above crash but not pinting to exact issue

Who is online

Users browsing this forum: Google [Bot], meta-externalagent, PerplexityBot, Qwantbot and 2 guests