ATECC608 Signing Fails After HTTP Requests (calib_random: NULL pointer)
Posted: Tue Apr 01, 2025 12:04 pm
I’m encountering intermittent NULL pointer errors in calib_random() when signing with an ATECC608 after making HTTP requests in ESP-IDF (v4.2.1).
error :
components\cryptoauthlib\cryptoauthlib\lib\calib\calib_random.c:54:e2:NULL pointer received
components\cryptoauthlib\cryptoauthlib\lib\calib\calib_sign.c:124:e2:calib_random - failed
E (585818) Signing failed!
E (585828) Could not sign packet.
It appears that initializing an esp_http_client somehow affects the ATECC608's state. When I manually reset the ATECC (calling atcab_release() followed by re-initialization) between the HTTP request and signing operations, the issue resolves.
Are there known conflicts between ESP-IDF's HTTP stack and cryptoauthlib?
Code: Select all
void update_info()
{
char url[256];
snprintf(url, sizeof(url), "https://test.com");
esp_http_client_config_t config = {
.url = url,
.cert_pem = NULL,
//.timeout_ms = 10000,
.disable_auto_redirect = true,
.event_handler = http_event_handler,
.transport_type = HTTP_TRANSPORT_OVER_SSL,
.use_global_ca_store = false,
.skip_cert_common_name_check = true,
};
take_atecc_sem(portMAX_DELAY);
esp_http_client_handle_t client; // = NULL;
client = esp_http_client_init(&config);
if (client == NULL)
{
ESP_LOGE("HTTP", "Failed to initialize client");
return;
}
esp_err_t err = esp_http_client_perform(client);
if (err == ESP_OK) {
ESP_LOGI("HTTP", "HTTPS request successful, Status = %d", esp_http_client_get_status_code(client));
//break;
} else {
ESP_LOGE("HTTP", "HTTP request failed: %s", esp_err_to_name(err));
}
esp_http_client_cleanup(client);
// atcab_release();
// atcab_init(&cfg_ateccx08a_i2c_default);
give_atecc_sem();
}components\cryptoauthlib\cryptoauthlib\lib\calib\calib_random.c:54:e2:NULL pointer received
components\cryptoauthlib\cryptoauthlib\lib\calib\calib_sign.c:124:e2:calib_random - failed
E (585818) Signing failed!
E (585828) Could not sign packet.
It appears that initializing an esp_http_client somehow affects the ATECC608's state. When I manually reset the ATECC (calling atcab_release() followed by re-initialization) between the HTTP request and signing operations, the issue resolves.
Are there known conflicts between ESP-IDF's HTTP stack and cryptoauthlib?