Remove useless linebreaks in log messages
This commit is contained in:
parent
cbca7c8f4c
commit
e244fff700
@ -29,12 +29,12 @@ static void seed_ctr_drbg_context(mbedtls_entropy_context *entropy, mbedtls_ctr_
|
||||
mbedtls_entropy_init(entropy);
|
||||
mbedtls_ctr_drbg_init(ctr_drbg);
|
||||
|
||||
ESP_LOGI(TAG, "Seed Mbedtls\n");
|
||||
ESP_LOGI(TAG, "Seed Mbedtls");
|
||||
if ((ret = mbedtls_ctr_drbg_seed(ctr_drbg, mbedtls_entropy_func, entropy,
|
||||
(const unsigned char *)pers,
|
||||
strlen(pers))) != 0)
|
||||
{
|
||||
ESP_LOGE(TAG, " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret);
|
||||
ESP_LOGE(TAG, " failed\n ! mbedtls_ctr_drbg_seed returned %d", ret);
|
||||
reboot();
|
||||
}
|
||||
}
|
||||
@ -54,7 +54,7 @@ bool crypto_gen_priv_key()
|
||||
mbedtls_ctr_drbg_context ctr_drbg;
|
||||
seed_ctr_drbg_context(&entropy, &ctr_drbg);
|
||||
|
||||
ESP_LOGI(TAG, "PK info from type\n");
|
||||
ESP_LOGI(TAG, "PK info from type");
|
||||
if ((ret = mbedtls_pk_setup(&key, mbedtls_pk_info_from_type(MBEDTLS_PK_ECKEY))) != 0)
|
||||
{
|
||||
ESP_LOGE(TAG, " failed\n ! mbedtls_pk_setup returned -0x%04x", (unsigned int)-ret);
|
||||
@ -62,7 +62,7 @@ bool crypto_gen_priv_key()
|
||||
}
|
||||
|
||||
// Generate private key
|
||||
ESP_LOGI(TAG, "Generate private key\n");
|
||||
ESP_LOGI(TAG, "Generate private key");
|
||||
ret = mbedtls_ecp_gen_key(ECPARAMS,
|
||||
mbedtls_pk_ec(key),
|
||||
mbedtls_ctr_drbg_random, &ctr_drbg);
|
||||
@ -74,7 +74,7 @@ bool crypto_gen_priv_key()
|
||||
}
|
||||
|
||||
// Export private key
|
||||
ESP_LOGI(TAG, "Export private key\n");
|
||||
ESP_LOGI(TAG, "Export private key");
|
||||
unsigned char *key_buff = malloc(PRV_KEY_DER_MAX_BYTES);
|
||||
if ((ret = mbedtls_pk_write_key_der(&key, key_buff, PRV_KEY_DER_MAX_BYTES)) < 1)
|
||||
{
|
||||
@ -108,7 +108,7 @@ void crypto_print_priv_key()
|
||||
mbedtls_ctr_drbg_context ctr_drbg;
|
||||
seed_ctr_drbg_context(&entropy, &ctr_drbg);
|
||||
|
||||
ESP_LOGI(TAG, "Parse private key (len = %d)\n", key_len);
|
||||
ESP_LOGI(TAG, "Parse private key (len = %d)", key_len);
|
||||
if ((ret = mbedtls_pk_parse_key(&key, key_buff, key_len, NULL, 0, mbedtls_ctr_drbg_random, &ctr_drbg)) != 0)
|
||||
{
|
||||
ESP_LOGE(TAG, " failed\n ! mbedtls_pk_parse_key returned -0x%04x",
|
||||
@ -117,7 +117,7 @@ void crypto_print_priv_key()
|
||||
}
|
||||
free(key_buff);
|
||||
|
||||
ESP_LOGI(TAG, "Show private key\n");
|
||||
ESP_LOGI(TAG, "Show private key");
|
||||
unsigned char *out = malloc(16000);
|
||||
memset(out, 0, 16000);
|
||||
if ((ret = mbedtls_pk_write_key_pem(&key, out, 16000)) != 0)
|
||||
@ -153,7 +153,7 @@ static bool crypto_get_priv_key_mpi(mbedtls_mpi *dst)
|
||||
mbedtls_ctr_drbg_context ctr_drbg;
|
||||
seed_ctr_drbg_context(&entropy, &ctr_drbg);
|
||||
|
||||
ESP_LOGI(TAG, "Parse private key (len = %d)\n", key_len);
|
||||
ESP_LOGI(TAG, "Parse private key (len = %d)", key_len);
|
||||
if ((ret = mbedtls_pk_parse_key(&key, key_buff, key_len, NULL, 0, mbedtls_ctr_drbg_random, &ctr_drbg)) != 0)
|
||||
{
|
||||
ESP_LOGE(TAG, " failed\n ! mbedtls_pk_parse_key returned -0x%04x",
|
||||
@ -190,7 +190,7 @@ char *crypto_get_csr()
|
||||
mbedtls_ctr_drbg_context ctr_drbg;
|
||||
seed_ctr_drbg_context(&entropy, &ctr_drbg);
|
||||
|
||||
ESP_LOGI(TAG, "Parse private key (len = %d)\n", key_len);
|
||||
ESP_LOGI(TAG, "Parse private key (len = %d)", key_len);
|
||||
if ((ret = mbedtls_pk_parse_key(&key, key_buff, key_len, NULL, 0, mbedtls_ctr_drbg_random, &ctr_drbg)) != 0)
|
||||
{
|
||||
ESP_LOGE(TAG, " failed\n ! mbedtls_pk_parse_key returned -0x%04x",
|
||||
@ -214,7 +214,7 @@ char *crypto_get_csr()
|
||||
reboot();
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Sign CSR with private key\n");
|
||||
ESP_LOGI(TAG, "Sign CSR with private key");
|
||||
mbedtls_x509write_csr_set_key(&req, &key);
|
||||
|
||||
char *csr = malloc(4096);
|
||||
|
@ -33,7 +33,7 @@ char *dev_name()
|
||||
char *dev = malloc(len + strlen(DEV_PREFIX) + 1);
|
||||
if (dev == NULL)
|
||||
{
|
||||
ESP_LOGE(TAG, "Failed to allocate memory to store dev name!\n");
|
||||
ESP_LOGE(TAG, "Failed to allocate memory to store dev name!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ static const char *TAG = "main";
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
esp_log_level_set("*", ESP_LOG_VERBOSE);
|
||||
esp_log_level_set("*", ESP_LOG_INFO);
|
||||
|
||||
system_show_free_memory();
|
||||
|
||||
@ -31,40 +31,40 @@ void app_main(void)
|
||||
// Initialize storage
|
||||
if (storage_init() == false)
|
||||
{
|
||||
ESP_LOGE(TAG, "Failed to init storage!\n");
|
||||
ESP_LOGE(TAG, "Failed to init storage!");
|
||||
reboot();
|
||||
}
|
||||
|
||||
// Give a name to the device
|
||||
if (dev_generate_name())
|
||||
{
|
||||
ESP_LOGI(TAG, "Generated a new device name\n");
|
||||
ESP_LOGI(TAG, "Generated a new device name");
|
||||
}
|
||||
|
||||
char *name = dev_name();
|
||||
ESP_LOGI(TAG, "Dev name: %s\n", name);
|
||||
ESP_LOGI(TAG, "Dev name: %s", name);
|
||||
free(name);
|
||||
|
||||
// Generate private key, if needed
|
||||
if (crypto_gen_priv_key())
|
||||
{
|
||||
ESP_LOGI(TAG, "Generated device private key!\n");
|
||||
ESP_LOGI(TAG, "Generated device private key!");
|
||||
}
|
||||
ESP_LOGI(TAG, "Device private key:\n");
|
||||
ESP_LOGI(TAG, "Device private key:");
|
||||
crypto_print_priv_key();
|
||||
|
||||
// Show current private key
|
||||
char *csr = crypto_get_csr();
|
||||
ESP_LOGI(TAG, "Current CSR:\n%s\n", csr);
|
||||
ESP_LOGI(TAG, "Current CSR:\n%s", csr);
|
||||
free(csr);
|
||||
|
||||
// Initialize network stack
|
||||
ESP_LOGI(TAG, "Initialize network\n");
|
||||
ESP_LOGI(TAG, "Initialize network");
|
||||
ethernet_init();
|
||||
ethernet_wait_for_network();
|
||||
|
||||
// Get if secure origin endpoint is known
|
||||
ESP_LOGI(TAG, "Check secure origin\n");
|
||||
ESP_LOGI(TAG, "Check secure origin");
|
||||
if (storage_get_secure_origin(NULL) == 0)
|
||||
{
|
||||
char *sec_ori = unsecure_api_get_secure_origin();
|
||||
@ -78,7 +78,7 @@ void app_main(void)
|
||||
}
|
||||
|
||||
// Print secure origin endpoint for debugging purposes
|
||||
ESP_LOGI(TAG, "Get secure origin\n");
|
||||
ESP_LOGI(TAG, "Get secure origin");
|
||||
char *sec_ori = calloc(SEC_ORIG_LEN, 1);
|
||||
assert(storage_get_secure_origin(sec_ori) > 0);
|
||||
ESP_LOGI(TAG, "Current secure origin: %s", sec_ori);
|
||||
@ -111,7 +111,7 @@ void app_main(void)
|
||||
// Check current device enrollment status
|
||||
ESP_LOGI(TAG, "Check enrollment status");
|
||||
enum DevEnrollmentStatus status = secure_api_get_device_enrollment_status();
|
||||
ESP_LOGI(TAG, "Current enrollment status: %d\n", status);
|
||||
ESP_LOGI(TAG, "Current enrollment status: %d", status);
|
||||
|
||||
switch (status)
|
||||
{
|
||||
|
@ -20,7 +20,7 @@ bool storage_init()
|
||||
esp_err_t err = nvs_flash_init();
|
||||
if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND)
|
||||
{
|
||||
ESP_LOGI(TAG, "Need to reset storage\n");
|
||||
ESP_LOGI(TAG, "Need to reset storage");
|
||||
|
||||
// NVS partition was truncated and needs to be erased
|
||||
// Retry nvs_flash_init
|
||||
|
Loading…
Reference in New Issue
Block a user