forked from espressif/arduino-esp32
v2.0.0 Add support for ESP32S2 and update ESP-IDF to 4.4 (#4996)
This is very much still work in progress and much more will change before the final 2.0.0 Some APIs have changed. New libraries have been added. LittleFS included. Co-authored-by: Seon Rozenblum <seonr@3sprockets.com> Co-authored-by: Me No Dev <me-no-dev@users.noreply.github.com> Co-authored-by: geeksville <kevinh@geeksville.com> Co-authored-by: Mike Dunston <m_dunston@comcast.net> Co-authored-by: Unexpected Maker <seon@unexpectedmaker.com> Co-authored-by: Seon Rozenblum <seonr@3sprockets.com> Co-authored-by: microDev <70126934+microDev1@users.noreply.github.com> Co-authored-by: tobozo <tobozo@users.noreply.github.com> Co-authored-by: bobobo1618 <bobobo1618@users.noreply.github.com> Co-authored-by: lorol <lorolouis@gmail.com> Co-authored-by: geeksville <kevinh@geeksville.com> Co-authored-by: Limor "Ladyada" Fried <limor@ladyada.net> Co-authored-by: Sweety <switi.mhaiske@espressif.com> Co-authored-by: Loick MAHIEUX <loick111@gmail.com> Co-authored-by: Larry Bernstone <lbernstone@gmail.com> Co-authored-by: Valerii Koval <valeros@users.noreply.github.com> Co-authored-by: 快乐的我531 <2302004040@qq.com> Co-authored-by: chegewara <imperiaonline4@gmail.com> Co-authored-by: Clemens Kirchgatterer <clemens@1541.org> Co-authored-by: Aron Rubin <aronrubin@gmail.com> Co-authored-by: Pete Lewis <601236+lewispg228@users.noreply.github.com>
This commit is contained in:
@ -0,0 +1,62 @@
|
||||
// Copyright 2017-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __ESP_TLS_ERROR_CAPTURE_INTERNAL_H__
|
||||
#define __ESP_TLS_ERROR_CAPTURE_INTERNAL_H__
|
||||
/**
|
||||
* Note: this is an implementation placeholder for error logger.
|
||||
* This version is internal to esp-tls component and only saves single esp_err of last occurred error
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Error tracker logging macro to enable mapping tracking errors internally
|
||||
* or using an external/global implementation
|
||||
*/
|
||||
#define ESP_INT_EVENT_TRACKER_CAPTURE(h, type, code) esp_tls_internal_event_tracker_capture(h, type, code)
|
||||
|
||||
/**
|
||||
* @brief Internal tracker capture error
|
||||
*
|
||||
* This implementation saves latest errors of available types
|
||||
*
|
||||
* @param[in] h esp-tls error handle
|
||||
* @param[in] err_type Specific error type
|
||||
* @param[int] code Error code to capture
|
||||
*
|
||||
*/
|
||||
void esp_tls_internal_event_tracker_capture(esp_tls_error_handle_t h, uint32_t type, int code);
|
||||
|
||||
/**
|
||||
* @brief Create internal tracker storage
|
||||
*
|
||||
* @return Error tracker handle if success or NULL if allocation error
|
||||
*/
|
||||
esp_tls_error_handle_t esp_tls_internal_event_tracker_create(void);
|
||||
|
||||
/**
|
||||
* @brief Destroy internal tracker storage
|
||||
*
|
||||
* @param[in] h esp-tls error handle
|
||||
*/
|
||||
void esp_tls_internal_event_tracker_destroy(esp_tls_error_handle_t h);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //__ESP_TLS_ERROR_CAPTURE_INTERNAL_H__
|
@ -0,0 +1,112 @@
|
||||
// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
#include "esp_tls.h"
|
||||
|
||||
/**
|
||||
* Internal Callback API for mbedtls_ssl_read
|
||||
*/
|
||||
ssize_t esp_mbedtls_read(esp_tls_t *tls, char *data, size_t datalen);
|
||||
|
||||
/**
|
||||
* Internal callback API for mbedtls_ssl_write
|
||||
*/
|
||||
ssize_t esp_mbedtls_write(esp_tls_t *tls, const char *data, size_t datalen);
|
||||
|
||||
/**
|
||||
* Internal Callback for mbedtls_handshake
|
||||
*/
|
||||
int esp_mbedtls_handshake(esp_tls_t *tls, const esp_tls_cfg_t *cfg);
|
||||
|
||||
/**
|
||||
* Internal Callback for mbedtls_cleanup , frees up all the memory used by mbedtls
|
||||
*/
|
||||
void esp_mbedtls_cleanup(esp_tls_t *tls);
|
||||
|
||||
/**
|
||||
* Internal Callback for Certificate verification for mbedtls
|
||||
*/
|
||||
void esp_mbedtls_verify_certificate(esp_tls_t *tls);
|
||||
|
||||
/**
|
||||
* Internal Callback for deleting the mbedtls connection
|
||||
*/
|
||||
void esp_mbedtls_conn_delete(esp_tls_t *tls);
|
||||
|
||||
/**
|
||||
* Internal Callback for mbedtls_get_bytes_avail
|
||||
*/
|
||||
ssize_t esp_mbedtls_get_bytes_avail(esp_tls_t *tls);
|
||||
|
||||
/**
|
||||
* Internal Callback for creating ssl handle for mbedtls
|
||||
*/
|
||||
esp_err_t esp_create_mbedtls_handle(const char *hostname, size_t hostlen, const void *cfg, esp_tls_t *tls);
|
||||
|
||||
/**
|
||||
* mbedTLS function for Initializing socket wrappers
|
||||
*/
|
||||
static inline void esp_mbedtls_net_init(esp_tls_t *tls)
|
||||
{
|
||||
mbedtls_net_init(&tls->server_fd);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ESP_TLS_SERVER
|
||||
/**
|
||||
* Internal Callback for set_server_config
|
||||
*
|
||||
* /note :- can only be used with mbedtls ssl library
|
||||
*/
|
||||
esp_err_t set_server_config(esp_tls_cfg_server_t *cfg, esp_tls_t *tls);
|
||||
|
||||
/**
|
||||
* Internal Callback for mbedtls_server_session_create
|
||||
*
|
||||
* /note :- The function can only be used with mbedtls ssl library
|
||||
*/
|
||||
int esp_mbedtls_server_session_create(esp_tls_cfg_server_t *cfg, int sockfd, esp_tls_t *tls);
|
||||
|
||||
/**
|
||||
* Internal Callback for mbedtls_server_session_delete
|
||||
*
|
||||
* /note :- The function can only be used with mbedtls ssl library
|
||||
*/
|
||||
void esp_mbedtls_server_session_delete(esp_tls_t *tls);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Internal Callback for set_client_config_function
|
||||
*/
|
||||
esp_err_t set_client_config(const char *hostname, size_t hostlen, esp_tls_cfg_t *cfg, esp_tls_t *tls);
|
||||
|
||||
/**
|
||||
* Internal Callback for mbedtls_init_global_ca_store
|
||||
*/
|
||||
esp_err_t esp_mbedtls_init_global_ca_store(void);
|
||||
|
||||
/**
|
||||
* Callback function for setting global CA store data for TLS/SSL using mbedtls
|
||||
*/
|
||||
esp_err_t esp_mbedtls_set_global_ca_store(const unsigned char *cacert_pem_buf, const unsigned int cacert_pem_bytes);
|
||||
|
||||
/**
|
||||
* Internal Callback for esp_tls_global_ca_store
|
||||
*/
|
||||
mbedtls_x509_crt *esp_mbedtls_get_global_ca_store(void);
|
||||
|
||||
/**
|
||||
* Callback function for freeing global ca store for TLS/SSL using mbedtls
|
||||
*/
|
||||
void esp_mbedtls_free_global_ca_store(void);
|
@ -0,0 +1,93 @@
|
||||
// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
#include "esp_tls.h"
|
||||
|
||||
/**
|
||||
* Internal Callback for creating ssl handle for wolfssl
|
||||
*/
|
||||
int esp_create_wolfssl_handle(const char *hostname, size_t hostlen, const void *cfg, esp_tls_t *tls);
|
||||
|
||||
/**
|
||||
* Internal Callback for wolfssl_handshake
|
||||
*/
|
||||
int esp_wolfssl_handshake(esp_tls_t *tls, const esp_tls_cfg_t *cfg);
|
||||
|
||||
/**
|
||||
* Internal Callback API for wolfssl_ssl_read
|
||||
*/
|
||||
ssize_t esp_wolfssl_read(esp_tls_t *tls, char *data, size_t datalen);
|
||||
|
||||
/**
|
||||
* Internal callback API for wolfssl_ssl_write
|
||||
*/
|
||||
ssize_t esp_wolfssl_write(esp_tls_t *tls, const char *data, size_t datalen);
|
||||
|
||||
/**
|
||||
* Internal Callback for wolfssl_cleanup , frees up all the memory used by wolfssl
|
||||
*/
|
||||
void esp_wolfssl_cleanup(esp_tls_t *tls);
|
||||
|
||||
/**
|
||||
* Internal Callback for Certificate verification for wolfssl
|
||||
*/
|
||||
void esp_wolfssl_verify_certificate(esp_tls_t *tls);
|
||||
|
||||
/**
|
||||
* Internal Callback for deleting the wolfssl connection
|
||||
*/
|
||||
void esp_wolfssl_conn_delete(esp_tls_t *tls);
|
||||
|
||||
/**
|
||||
* Internal Callback for wolfssl_get_bytes_avail
|
||||
*/
|
||||
ssize_t esp_wolfssl_get_bytes_avail(esp_tls_t *tls);
|
||||
|
||||
/**
|
||||
* Callback function for setting global CA store data for TLS/SSL using wolfssl
|
||||
*/
|
||||
esp_err_t esp_wolfssl_set_global_ca_store(const unsigned char *cacert_pem_buf, const unsigned int cacert_pem_bytes);
|
||||
|
||||
/**
|
||||
* Callback function for freeing global ca store for TLS/SSL using wolfssl
|
||||
*/
|
||||
void esp_wolfssl_free_global_ca_store(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* Callback function for Initializing the global ca store for TLS?SSL using wolfssl
|
||||
*/
|
||||
esp_err_t esp_wolfssl_init_global_ca_store(void);
|
||||
|
||||
/**
|
||||
* wolfSSL function for Initializing socket wrappers (no-operation for wolfSSL)
|
||||
*/
|
||||
static inline void esp_wolfssl_net_init(esp_tls_t *tls)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ESP_TLS_SERVER
|
||||
|
||||
/**
|
||||
* Function to Create ESP-TLS Server session with wolfssl Stack
|
||||
*/
|
||||
int esp_wolfssl_server_session_create(esp_tls_cfg_server_t *cfg, int sockfd, esp_tls_t *tls);
|
||||
|
||||
/*
|
||||
* Delete Server Session
|
||||
*/
|
||||
void esp_wolfssl_server_session_delete(esp_tls_t *tls);
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user