Lines Matching refs:ret
73 int ret; in esp_create_mbedtls_handle() local
100 if ((ret = mbedtls_ctr_drbg_seed(&tls->ctr_drbg, in esp_create_mbedtls_handle()
102 ESP_LOGE(TAG, "mbedtls_ctr_drbg_seed returned -0x%x", -ret); in esp_create_mbedtls_handle()
103 ESP_INT_EVENT_TRACKER_CAPTURE(tls->error_handle, ESP_TLS_ERR_TYPE_MBEDTLS, -ret); in esp_create_mbedtls_handle()
114 if ((ret = mbedtls_ssl_setup(&tls->ssl, &tls->conf)) != 0) { in esp_create_mbedtls_handle()
115 ESP_LOGE(TAG, "mbedtls_ssl_setup returned -0x%x", -ret); in esp_create_mbedtls_handle()
116 ESP_INT_EVENT_TRACKER_CAPTURE(tls->error_handle, ESP_TLS_ERR_TYPE_MBEDTLS, -ret); in esp_create_mbedtls_handle()
132 int ret; in esp_mbedtls_handshake() local
133 ret = mbedtls_ssl_handshake(&tls->ssl); in esp_mbedtls_handshake()
134 if (ret == 0) { in esp_mbedtls_handshake()
141 if (ret != ESP_TLS_ERR_SSL_WANT_READ && ret != ESP_TLS_ERR_SSL_WANT_WRITE) { in esp_mbedtls_handshake()
142 ESP_LOGE(TAG, "mbedtls_ssl_handshake returned -0x%x", -ret); in esp_mbedtls_handshake()
143 ESP_INT_EVENT_TRACKER_CAPTURE(tls->error_handle, ESP_TLS_ERR_TYPE_MBEDTLS, -ret); in esp_mbedtls_handshake()
161 ssize_t ret = mbedtls_ssl_read(&tls->ssl, (unsigned char *)data, datalen); in esp_mbedtls_read() local
162 if (ret < 0) { in esp_mbedtls_read()
163 if (ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) { in esp_mbedtls_read()
166 if (ret != ESP_TLS_ERR_SSL_WANT_READ && ret != ESP_TLS_ERR_SSL_WANT_WRITE) { in esp_mbedtls_read()
167 ESP_INT_EVENT_TRACKER_CAPTURE(tls->error_handle, ESP_TLS_ERR_TYPE_MBEDTLS, -ret); in esp_mbedtls_read()
168 ESP_LOGE(TAG, "read error :%d:", ret); in esp_mbedtls_read()
171 return ret; in esp_mbedtls_read()
185 ssize_t ret = mbedtls_ssl_write(&tls->ssl, (unsigned char*) data + written, write_len); in esp_mbedtls_write() local
186 if (ret <= 0) { in esp_mbedtls_write()
187 … if (ret != ESP_TLS_ERR_SSL_WANT_READ && ret != ESP_TLS_ERR_SSL_WANT_WRITE && ret != 0) { in esp_mbedtls_write()
188 ESP_INT_EVENT_TRACKER_CAPTURE(tls->error_handle, ESP_TLS_ERR_TYPE_MBEDTLS, -ret); in esp_mbedtls_write()
190 ESP_LOGE(TAG, "write error :%d:", ret); in esp_mbedtls_write()
191 return ret; in esp_mbedtls_write()
194 … ESP_LOGD(TAG, "mbedtls_ssl_write() returned %d, already written %d, exitting...", ret, written); in esp_mbedtls_write()
198 written += ret; in esp_mbedtls_write()
272 int ret = mbedtls_x509_crt_parse(tls->cacert_ptr, cacert, cacert_len); in set_ca_cert() local
273 if (ret < 0) { in set_ca_cert()
274 ESP_LOGE(TAG, "mbedtls_x509_crt_parse returned -0x%x", -ret); in set_ca_cert()
275 ESP_INT_EVENT_TRACKER_CAPTURE(tls->error_handle, ESP_TLS_ERR_TYPE_MBEDTLS, -ret); in set_ca_cert()
278 if (ret > 0) { in set_ca_cert()
281 …ESP_LOGW(TAG, "mbedtls_x509_crt_parse was partly successful. No. of failed certificates: %d", ret); in set_ca_cert()
292 int ret; in set_pki_context() local
301 …ret = mbedtls_x509_crt_parse(pki->public_cert, pki->publiccert_pem_buf, pki->publiccert_pem_bytes); in set_pki_context()
302 if (ret < 0) { in set_pki_context()
303 ESP_LOGE(TAG, "mbedtls_x509_crt_parse returned -0x%x", -ret); in set_pki_context()
304 ESP_INT_EVENT_TRACKER_CAPTURE(tls->error_handle, ESP_TLS_ERR_TYPE_MBEDTLS, -ret); in set_pki_context()
310 ret = esp_mbedtls_init_pk_ctx_for_ds(pki); in set_pki_context()
311 if (ret != ESP_OK) { in set_pki_context()
313 return ret; in set_pki_context()
318 ret = mbedtls_pk_parse_key(pki->pk_key, pki->privkey_pem_buf, pki->privkey_pem_bytes, in set_pki_context()
324 if (ret < 0) { in set_pki_context()
325 ESP_LOGE(TAG, "mbedtls_pk_parse_keyfile returned -0x%x", -ret); in set_pki_context()
326 ESP_INT_EVENT_TRACKER_CAPTURE(tls->error_handle, ESP_TLS_ERR_TYPE_MBEDTLS, -ret); in set_pki_context()
330 ret = mbedtls_ssl_conf_own_cert(&tls->conf, pki->public_cert, pki->pk_key); in set_pki_context()
331 if (ret < 0) { in set_pki_context()
332 ESP_LOGE(TAG, "mbedtls_ssl_conf_own_cert returned -0x%x", -ret); in set_pki_context()
333 ESP_INT_EVENT_TRACKER_CAPTURE(tls->error_handle, ESP_TLS_ERR_TYPE_MBEDTLS, -ret); in set_pki_context()
361 int ret; in set_server_config() local
363 if ((ret = mbedtls_ssl_config_defaults(&tls->conf, in set_server_config()
367 ESP_LOGE(TAG, "mbedtls_ssl_config_defaults returned %d", ret); in set_server_config()
368 ESP_INT_EVENT_TRACKER_CAPTURE(tls->error_handle, ESP_TLS_ERR_TYPE_MBEDTLS, -ret); in set_server_config()
415 int ret; in set_client_config() local
428 if ((ret = mbedtls_ssl_set_hostname(&tls->ssl, use_host)) != 0) { in set_client_config()
429 ESP_LOGE(TAG, "mbedtls_ssl_set_hostname returned -0x%x", -ret); in set_client_config()
430 ESP_INT_EVENT_TRACKER_CAPTURE(tls->error_handle, ESP_TLS_ERR_TYPE_MBEDTLS, -ret); in set_client_config()
437 if ((ret = mbedtls_ssl_config_defaults(&tls->conf, in set_client_config()
441 ESP_LOGE(TAG, "mbedtls_ssl_config_defaults returned -0x%x", -ret); in set_client_config()
442 ESP_INT_EVENT_TRACKER_CAPTURE(tls->error_handle, ESP_TLS_ERR_TYPE_MBEDTLS, -ret); in set_client_config()
452 if ((ret = mbedtls_ssl_conf_alpn_protocols(&tls->conf, cfg->alpn_protos)) != 0) { in set_client_config()
453 ESP_LOGE(TAG, "mbedtls_ssl_conf_alpn_protocols returned -0x%x", -ret); in set_client_config()
454 ESP_INT_EVENT_TRACKER_CAPTURE(tls->error_handle, ESP_TLS_ERR_TYPE_MBEDTLS, -ret); in set_client_config()
488 ret = mbedtls_ssl_conf_psk(&tls->conf, cfg->psk_hint_key->key, cfg->psk_hint_key->key_size, in set_client_config()
490 if (ret != 0) { in set_client_config()
491 ESP_LOGE(TAG, "mbedtls_ssl_conf_psk returned -0x%x", -ret); in set_client_config()
492 ESP_INT_EVENT_TRACKER_CAPTURE(tls->error_handle, ESP_TLS_ERR_TYPE_MBEDTLS, -ret); in set_client_config()
510 ret = esp_set_atecc608a_pki_context(tls, (esp_tls_cfg_t *)cfg); in set_client_config()
511 if (ret != ESP_OK) { in set_client_config()
512 return ret; in set_client_config()
590 int ret; in esp_mbedtls_server_session_create() local
591 while ((ret = mbedtls_ssl_handshake(&tls->ssl)) != 0) { in esp_mbedtls_server_session_create()
592 if (ret != ESP_TLS_ERR_SSL_WANT_READ && ret != ESP_TLS_ERR_SSL_WANT_WRITE) { in esp_mbedtls_server_session_create()
593 ESP_LOGE(TAG, "mbedtls_ssl_handshake returned %d", ret); in esp_mbedtls_server_session_create()
595 return ret; in esp_mbedtls_server_session_create()
636 int ret; in esp_mbedtls_set_global_ca_store() local
638 ret = esp_mbedtls_init_global_ca_store(); in esp_mbedtls_set_global_ca_store()
639 if (ret != ESP_OK) { in esp_mbedtls_set_global_ca_store()
640 return ret; in esp_mbedtls_set_global_ca_store()
643 ret = mbedtls_x509_crt_parse(global_cacert, cacert_pem_buf, cacert_pem_bytes); in esp_mbedtls_set_global_ca_store()
644 if (ret < 0) { in esp_mbedtls_set_global_ca_store()
645 ESP_LOGE(TAG, "mbedtls_x509_crt_parse returned -0x%x", -ret); in esp_mbedtls_set_global_ca_store()
650 } else if (ret > 0) { in esp_mbedtls_set_global_ca_store()
651 …ESP_LOGE(TAG, "mbedtls_x509_crt_parse was partly successful. No. of failed certificates: %d", ret); in esp_mbedtls_set_global_ca_store()
675 int ret = atcab_init(&cfg_ateccx08a_i2c_default); in esp_init_atecc608a() local
676 if(ret != 0) { in esp_init_atecc608a()
677 ESP_LOGE(TAG, "Failed\n !atcab_init returned %02x", ret); in esp_init_atecc608a()
685 int ret = 0; in esp_set_atecc608a_pki_context() local
691 if (ret != ESP_OK) { in esp_set_atecc608a_pki_context()
696 if (ret != ESP_OK) { in esp_set_atecc608a_pki_context()
701 ret = tng_get_device_cert_def(&cert_def); in esp_set_atecc608a_pki_context()
702 if (ret != 0) { in esp_set_atecc608a_pki_context()
708 ret = atca_mbedtls_cert_add(&tls->clientcert, cert_def); in esp_set_atecc608a_pki_context()
709 if (ret != 0) { in esp_set_atecc608a_pki_context()
710 ESP_LOGE(TAG, "Failed to parse cert from device, return %02x", ret); in esp_set_atecc608a_pki_context()
715 if (ret != ESP_OK) { in esp_set_atecc608a_pki_context()
721 …ret = mbedtls_x509_crt_parse(&tls->clientcert, (const unsigned char*)cfg->clientcert_buf, cfg->cli… in esp_set_atecc608a_pki_context()
722 if (ret < 0) { in esp_set_atecc608a_pki_context()
723 ESP_LOGE(TAG, "mbedtls_x509_crt_parse returned -0x%x", -ret); in esp_set_atecc608a_pki_context()
724 ESP_INT_EVENT_TRACKER_CAPTURE(tls->error_handle, ESP_TLS_ERR_TYPE_MBEDTLS, -ret); in esp_set_atecc608a_pki_context()
732 ret = atca_mbedtls_pk_init(&tls->clientkey, 0); in esp_set_atecc608a_pki_context()
733 if (ret != 0) { in esp_set_atecc608a_pki_context()
735 ESP_INT_EVENT_TRACKER_CAPTURE(tls->error_handle, ESP_TLS_ERR_TYPE_MBEDTLS, -ret); in esp_set_atecc608a_pki_context()
739 ret = mbedtls_ssl_conf_own_cert(&tls->conf, &tls->clientcert, &tls->clientkey); in esp_set_atecc608a_pki_context()
740 if (ret != 0) { in esp_set_atecc608a_pki_context()
741 ESP_LOGE(TAG, "Failed\n ! mbedtls_ssl_conf_own_cert returned -0x%x", ret); in esp_set_atecc608a_pki_context()
742 ESP_INT_EVENT_TRACKER_CAPTURE(tls->error_handle, ESP_TLS_ERR_TYPE_MBEDTLS, -ret); in esp_set_atecc608a_pki_context()
752 int ret = -1; in esp_mbedtls_init_pk_ctx_for_ds() local
756 …if ((ret = mbedtls_pk_setup_rsa_alt(((const esp_tls_pki_t*)pki)->pk_key, &rsakey, NULL, esp_ds_rsa… in esp_mbedtls_init_pk_ctx_for_ds()
758 ESP_LOGE(TAG, "Error in mbedtls_pk_setup_rsa_alt, returned %02x", ret); in esp_mbedtls_init_pk_ctx_for_ds()
761 ret = esp_ds_init_data_ctx(((const esp_tls_pki_t*)pki)->esp_ds_data); in esp_mbedtls_init_pk_ctx_for_ds()
762 if (ret != ESP_OK) { in esp_mbedtls_init_pk_ctx_for_ds()