esp-rs / esp-mbedtls Goto Github PK
View Code? Open in Web Editor NEWmbedtls for ESP32 bare-metal
License: Apache License 2.0
mbedtls for ESP32 bare-metal
License: Apache License 2.0
This took quite a while to figure out. At first I realized that we couldn't read single bytes from AsyncConnectedSession::read()
by calling it with a single byte slice.
It turns out the issue is with how the bytes are pulled in:
sync_receive(ctx: *mut c_void, buf: *mut c_uchar, len: usize) -> c_int
.
By running async_server.rs
with loglevel set to debug, and calling connected_session.read()
with a buffer of len 489
*, the second iteration of the loop freezes and we can notice the following output:
DEBUG - async read called
DEBUG - <<< got 511 bytes from socket
DEBUG - <<< read data from mbedtls
DEBUG - *** sync rcv, len=5
DEBUG - *** pulled 5 bytes from rx-buffer
DEBUG - *** sync rcv, len=506
DEBUG - *** pulled 506 bytes from rx-buffer
DEBUG - <<< mbedtls returned 489
DEBUG - async read called
read error: Unknown
The following line reads 489 bytes which is the correct value as its the size of the buffer, but at the same time, 511 bytes in total get pulled from the buffer.
esp-mbedtls/esp-mbedtls/src/lib.rs
Line 826 in b339fe8
Also, unrelated but I think this line should compare rx_buffer
, not tx_buffer
:
esp-mbedtls/esp-mbedtls/src/lib.rs
Line 875 in b339fe8
EDIT: The given values, 489 and 511 are arbritrary, as they depend of the headers. For complete usability, it should be able to read a single byte at a time, without too much additional processing latency.
Currently, this buffer leads to stack overflows in my project so I would like to allocate it static
ally.
esp-mbedtls/esp-mbedtls/src/lib.rs
Lines 686 to 687 in 27c781f
When enabling the logging in syslog, which printf calls, by enabling the wifi-logs
feature, calls to mbedtls_printf
in the C library are logged as info, except for any of them that don't have arguments.
Example:
This will log
mbedtls_printf(" SHA-%d test #%d: ", 512 - is384 * 128, i + 1);
This will not log
mbedtls_printf("passed\n");
This is an issue similar as esp-rs/esp-wifi-sys#216 where Ok(0)
is returned from read()
if there's no data.
This causes issues when trying to use the read()
impl from inside other crates, since it might interpret Ok(0)
as an EOF. This is what happens initially during a request handshake.
This forces the use of something like:
loop {
match tls.read(&mut temp_buffer).await {
Ok(0) => continue,
Ok(_) => break,
Err(TlsError::Eof) => {
log::error!("EOF");
break;
}
Err(e) => {
log::error!("Read Error {:?}", e);
break;
}
};
}
and then use this temporary buffer for the other crates.
For example, trying to use the current read()
impl inside https://github.com/drogue-iot/reqwless/blob/f23567d8d178dd837332b503fe983ba4931d8b40/src/response.rs#L47-L58 will result in no data being read.
I've tried to run the following examples after a clean git clone and they all fail due to various issues:
EDIT: After further testing, the problem seems to occur on Xtensa targets. It had issues on esp32s3
but with esp32c3
everything is running without any failure.
Here's the output from running async_client:
Waiting to get IP address...
Got IP: 192.168.69.165/24
connecting...
Start tls connect
Exception occured 'InstrProhibited'
Context
PC=0x00000000 PS=0x00060a10
0x00000000 - XT_STK_PC
at ??:??
0x00060a10 - PS_WOE
at ??:??
A0=0x8037b2eb A1=0x3fc9b900 A2=0x00000001 A3=0x00000000 A4=0x3fcbbfe0
0x8037b2eb - _rtc_fast_data_end
at ??:??
0x3fc9b900 - _ZN8esp_wifi7preempt10TASK_STACK17hc849bc2d8dfdc35eE.llvm.8558853931319064652
at ??:??
0x00000001 - XT_STK_PC
at ??:??
0x00000000 - XT_STK_PC
at ??:??
0x3fcbbfe0 - g_pm
at ??:??
A5=0x3fcbbfe0 A6=0x3fcef940 A7=0x1d800160 A8=0x820a44aa A9=0x00000000
0x3fcbbfe0 - g_pm
at ??:??
0x3fcef940 - g_osi_funcs_p
at ??:??
0x1d800160 - PS_WOE
at ??:??
0x820a44aa - _rtc_fast_data_end
at ??:??
0x00000000 - XT_STK_PC
at ??:??
A10=0x00019000 A11=0x00000001 A12=0x3fc9b900 A13=0xeeeeeeef A14=0x00000000
0x00019000 - RESERVE_ICACHE
at ??:??
0x00000001 - XT_STK_PC
at ??:??
0x3fc9b900 - _ZN8esp_wifi7preempt10TASK_STACK17hc849bc2d8dfdc35eE.llvm.8558853931319064652
at ??:??
0xeeeeeeef - _rtc_fast_data_end
at ??:??
0x00000000 - XT_STK_PC
at ??:??
A15=0x00000006
0x00000006 - XT_STK_PS
at ??:??
SAR=00000004
EXCCAUSE=0x00000014 EXCVADDR=0x00000000
0x00000014 - XT_STK_A3
at ??:??
0x00000000 - XT_STK_PC
at ??:??
LBEG=0x00000000 LEND=0x00000000 LCOUNT=0x00000000
0x00000000 - XT_STK_PC
at ??:??
0x00000000 - XT_STK_PC
at ??:??
0x00000000 - XT_STK_PC
at ??:??
THREADPTR=0x00000000
0x00000000 - XT_STK_PC
at ??:??
SCOMPARE1=0x00000001
0x00000001 - XT_STK_PC
at ??:??
BR=0x00000000
0x00000000 - XT_STK_PC
at ??:??
ACCLO=0x00000000 ACCHI=0x00000000
0x00000000 - XT_STK_PC
at ??:??
0x00000000 - XT_STK_PC
at ??:??
M0=0x00000000 M1=0x00000000 M2=0x00000000 M3=0x00000000
0x00000000 - XT_STK_PC
at ??:??
0x00000000 - XT_STK_PC
at ??:??
0x00000000 - XT_STK_PC
at ??:??
0x00000000 - XT_STK_PC
at ??:??
F64R_LO=0x00000000 F64R_HI=0x00000000 F64S=0x00000000
0x00000000 - XT_STK_PC
at ??:??
0x00000000 - XT_STK_PC
at ??:??
0x00000000 - XT_STK_PC
at ??:??
FCR=0x00000000 FSR=0x00000000
0x00000000 - XT_STK_PC
at ??:??
0x00000000 - XT_STK_PC
at ??:??
F0=0x00000000 F1=0x00000000 F2=0x00000000 F3=0x00000000 F4=0x00000000
0x00000000 - XT_STK_PC
at ??:??
0x00000000 - XT_STK_PC
at ??:??
0x00000000 - XT_STK_PC
at ??:??
0x00000000 - XT_STK_PC
at ??:??
0x00000000 - XT_STK_PC
at ??:??
F5=0x00000000 F6=0x00000000 F7=0x00000000 F8=0x00000000 F9=0x00000000
0x00000000 - XT_STK_PC
at ??:??
0x00000000 - XT_STK_PC
at ??:??
0x00000000 - XT_STK_PC
at ??:??
0x00000000 - XT_STK_PC
at ??:??
0x00000000 - XT_STK_PC
at ??:??
F10=0x00000000 F11=0x00000000 F12=0x00000000 F13=0x00000000 F14=0x00000000
0x00000000 - XT_STK_PC
at ??:??
0x00000000 - XT_STK_PC
at ??:??
0x00000000 - XT_STK_PC
at ??:??
0x00000000 - XT_STK_PC
at ??:??
0x00000000 - XT_STK_PC
at ??:??
F15=0x00000000
0x00000000 - XT_STK_PC
at ??:??
0x4003d024
0x4003d024 - rom_rx_gain_force
at ??:??
0x4037a49c
0x4037a49c - ppTask
at ??:??
0x42021f84
0x42021f84 - core::sync::atomic::atomic_load
at /home/anthony/.rustup/toolchains/esp/lib/rustlib/src/rust/library/core/src/sync/atomic.rs:3184
0x40000000
0x40000000 - ets_rom_layout_p
at ??:??
I'm a noob, but it seems that risc-v is set statically here when the rest of the file seems to follow an "xtensa or riscv" approach. Just pointing it out in-case it is something, feel free to close otherwise. :)
Line 361 in 360bf59
When I try to generate bindings on a clean repo, using the following command:
cargo +stable run --manifest-path ./xtask/Cargo.toml
I get the following bindings diffs:
diff --git a/esp-mbedtls-sys/src/bindings.rs b/esp-mbedtls-sys/src/bindings.rs
index 6fbb936..4f0112b 100644
--- a/esp-mbedtls-sys/src/bindings.rs
+++ b/esp-mbedtls-sys/src/bindings.rs
@@ -206,125 +206,8 @@ pub const PSA_WANT_KEY_TYPE_DERIVE: u32 = 1;
pub const PSA_WANT_KEY_TYPE_PASSWORD: u32 = 1;
pub const PSA_WANT_KEY_TYPE_PASSWORD_HASH: u32 = 1;
pub const PSA_WANT_KEY_TYPE_RAW_DATA: u32 = 1;
-pub const _LIBC_LIMITS_H_: u32 = 1;
-pub const __NEWLIB_H__: u32 = 1;
-pub const _NEWLIB_VERSION_H__: u32 = 1;
-pub const _NEWLIB_VERSION: &[u8; 6usize] = b"3.3.0\0";
-pub const __NEWLIB__: u32 = 3;
-pub const __NEWLIB_MINOR__: u32 = 3;
-pub const __NEWLIB_PATCHLEVEL__: u32 = 0;
-pub const _WANT_IO_C99_FORMATS: u32 = 1;
-pub const _WANT_IO_LONG_LONG: u32 = 1;
-pub const _WANT_IO_POS_ARGS: u32 = 1;
-pub const _WANT_REENT_SMALL: u32 = 1;
-pub const _REENT_CHECK_VERIFY: u32 = 1;
-pub const _MB_LEN_MAX: u32 = 1;
-pub const _ICONV_ENABLED: u32 = 1;
-pub const HAVE_INITFINI_ARRAY: u32 = 1;
-pub const _ATEXIT_DYNAMIC_ALLOC: u32 = 1;
-pub const _HAVE_LONG_DOUBLE: u32 = 1;
-pub const _HAVE_CC_INHIBIT_LOOP_TO_LIBCALL: u32 = 1;
-pub const _FVWRITE_IN_STREAMIO: u32 = 1;
-pub const _FSEEK_OPTIMIZATION: u32 = 1;
-pub const _UNBUF_STREAM_OPT: u32 = 1;
-pub const _RETARGETABLE_LOCKING: u32 = 1;
-pub const _WANT_USE_LONG_TIME_T: u32 = 1;
-pub const _DEFAULT_SOURCE: u32 = 1;
-pub const _POSIX_SOURCE: u32 = 1;
-pub const _POSIX_C_SOURCE: u32 = 200809;
-pub const _ATFILE_SOURCE: u32 = 1;
-pub const __ATFILE_VISIBLE: u32 = 1;
-pub const __BSD_VISIBLE: u32 = 1;
-pub const __GNU_VISIBLE: u32 = 0;
-pub const __ISO_C_VISIBLE: u32 = 2011;
-pub const __LARGEFILE_VISIBLE: u32 = 0;
-pub const __MISC_VISIBLE: u32 = 1;
-pub const __POSIX_VISIBLE: u32 = 200809;
-pub const __SVID_VISIBLE: u32 = 1;
-pub const __XSI_VISIBLE: u32 = 0;
-pub const __SSP_FORTIFY_LEVEL: u32 = 0;
-pub const _POSIX_THREADS: u32 = 1;
-pub const _POSIX_TIMEOUTS: u32 = 1;
-pub const _POSIX_TIMERS: u32 = 1;
-pub const _POSIX_MONOTONIC_CLOCK: u32 = 200112;
-pub const _POSIX_CLOCK_SELECTION: u32 = 200112;
-pub const _UNIX98_THREAD_MUTEX_ATTRIBUTES: u32 = 1;
-pub const __have_longlong64: u32 = 1;
-pub const __have_long32: u32 = 1;
-pub const ___int8_t_defined: u32 = 1;
-pub const ___int16_t_defined: u32 = 1;
-pub const ___int32_t_defined: u32 = 1;
-pub const ___int64_t_defined: u32 = 1;
-pub const ___int_least8_t_defined: u32 = 1;
-pub const ___int_least16_t_defined: u32 = 1;
-pub const ___int_least32_t_defined: u32 = 1;
-pub const ___int_least64_t_defined: u32 = 1;
-pub const __GNUCLIKE_ASM: u32 = 3;
-pub const __GNUCLIKE___TYPEOF: u32 = 1;
-pub const __GNUCLIKE___OFFSETOF: u32 = 1;
-pub const __GNUCLIKE___SECTION: u32 = 1;
-pub const __GNUCLIKE_CTOR_SECTION_HANDLING: u32 = 1;
-pub const __GNUCLIKE_BUILTIN_CONSTANT_P: u32 = 1;
-pub const __GNUCLIKE_BUILTIN_VARARGS: u32 = 1;
-pub const __GNUCLIKE_BUILTIN_STDARG: u32 = 1;
-pub const __GNUCLIKE_BUILTIN_VAALIST: u32 = 1;
-pub const __GNUC_VA_LIST_COMPATIBILITY: u32 = 1;
-pub const __GNUCLIKE_BUILTIN_NEXT_ARG: u32 = 1;
-pub const __GNUCLIKE_BUILTIN_MEMCPY: u32 = 1;
-pub const __CC_SUPPORTS_INLINE: u32 = 1;
-pub const __CC_SUPPORTS___INLINE: u32 = 1;
-pub const __CC_SUPPORTS___INLINE__: u32 = 1;
-pub const __CC_SUPPORTS___FUNC__: u32 = 1;
-pub const __CC_SUPPORTS_WARNING: u32 = 1;
-pub const __CC_SUPPORTS_VARADIC_XXX: u32 = 1;
-pub const __CC_SUPPORTS_DYNAMIC_ARRAY_INIT: u32 = 1;
-pub const ARG_MAX: u32 = 4096;
-pub const CHILD_MAX: u32 = 40;
-pub const LINK_MAX: u32 = 32767;
-pub const MAX_CANON: u32 = 255;
-pub const MAX_INPUT: u32 = 255;
-pub const NAME_MAX: u32 = 255;
-pub const NGROUPS_MAX: u32 = 16;
-pub const OPEN_MAX: u32 = 64;
-pub const PATH_MAX: u32 = 1024;
-pub const PIPE_BUF: u32 = 512;
-pub const IOV_MAX: u32 = 1024;
-pub const BC_BASE_MAX: u32 = 99;
-pub const BC_DIM_MAX: u32 = 2048;
-pub const BC_SCALE_MAX: u32 = 99;
-pub const BC_STRING_MAX: u32 = 1000;
-pub const COLL_WEIGHTS_MAX: u32 = 0;
-pub const EXPR_NEST_MAX: u32 = 32;
-pub const LINE_MAX: u32 = 2048;
-pub const RE_DUP_MAX: u32 = 255;
pub const MB_LEN_MAX: u32 = 1;
-pub const NL_ARGMAX: u32 = 32;
pub const CHAR_MIN: u32 = 0;
-pub const _POSIX2_RE_DUP_MAX: u32 = 255;
-pub const __int20: u32 = 2;
-pub const __int20__: u32 = 2;
-pub const __INT8: &[u8; 3usize] = b"hh\0";
-pub const __INT16: &[u8; 2usize] = b"h\0";
-pub const __INT64: &[u8; 3usize] = b"ll\0";
-pub const __FAST8: &[u8; 3usize] = b"hh\0";
-pub const __FAST16: &[u8; 2usize] = b"h\0";
-pub const __FAST64: &[u8; 3usize] = b"ll\0";
-pub const __LEAST8: &[u8; 3usize] = b"hh\0";
-pub const __LEAST16: &[u8; 2usize] = b"h\0";
-pub const __LEAST64: &[u8; 3usize] = b"ll\0";
-pub const __int8_t_defined: u32 = 1;
-pub const __int16_t_defined: u32 = 1;
-pub const __int32_t_defined: u32 = 1;
-pub const __int64_t_defined: u32 = 1;
-pub const __int_least8_t_defined: u32 = 1;
-pub const __int_least16_t_defined: u32 = 1;
-pub const __int_least32_t_defined: u32 = 1;
-pub const __int_least64_t_defined: u32 = 1;
-pub const __int_fast8_t_defined: u32 = 1;
-pub const __int_fast16_t_defined: u32 = 1;
-pub const __int_fast32_t_defined: u32 = 1;
-pub const __int_fast64_t_defined: u32 = 1;
-pub const WINT_MIN: u32 = 0;
pub const MBEDTLS_ERR_MPI_FILE_IO_ERROR: i32 = -2;
pub const MBEDTLS_ERR_MPI_BAD_INPUT_DATA: i32 = -4;
pub const MBEDTLS_ERR_MPI_INVALID_CHARACTER: i32 = -6;
@@ -1067,26 +950,25 @@ pub const MBEDTLS_CTR_DRBG_MAX_SEED_INPUT: u32 = 384;
pub const MBEDTLS_CTR_DRBG_PR_OFF: u32 = 0;
pub const MBEDTLS_CTR_DRBG_PR_ON: u32 = 1;
pub const MBEDTLS_CTR_DRBG_ENTROPY_NONCE_LEN: u32 = 0;
-pub type __int8_t = crate::c_types::c_schar;
-pub type __uint8_t = crate::c_types::c_uchar;
-pub type __int16_t = crate::c_types::c_short;
-pub type __uint16_t = crate::c_types::c_ushort;
-pub type __int32_t = crate::c_types::c_int;
-pub type __uint32_t = crate::c_types::c_uint;
-pub type __int64_t = crate::c_types::c_longlong;
-pub type __uint64_t = crate::c_types::c_ulonglong;
-pub type __int_least8_t = crate::c_types::c_schar;
-pub type __uint_least8_t = crate::c_types::c_uchar;
-pub type __int_least16_t = crate::c_types::c_short;
-pub type __uint_least16_t = crate::c_types::c_ushort;
-pub type __int_least32_t = crate::c_types::c_int;
-pub type __uint_least32_t = crate::c_types::c_uint;
-pub type __int_least64_t = crate::c_types::c_longlong;
-pub type __uint_least64_t = crate::c_types::c_ulonglong;
-pub type __intmax_t = crate::c_types::c_longlong;
-pub type __uintmax_t = crate::c_types::c_ulonglong;
-pub type __intptr_t = crate::c_types::c_int;
-pub type __uintptr_t = crate::c_types::c_uint;
+pub type int_least64_t = i64;
+pub type uint_least64_t = u64;
+pub type int_fast64_t = i64;
+pub type uint_fast64_t = u64;
+pub type int_least32_t = i32;
+pub type uint_least32_t = u32;
+pub type int_fast32_t = i32;
+pub type uint_fast32_t = u32;
+pub type int_least16_t = i16;
+pub type uint_least16_t = u16;
+pub type int_fast16_t = i16;
+pub type uint_fast16_t = u16;
+pub type int_least8_t = i8;
+pub type uint_least8_t = u8;
+pub type int_fast8_t = i8;
+pub type uint_fast8_t = u8;
+pub type intmax_t = crate::c_types::c_longlong;
+pub type uintmax_t = crate::c_types::c_ulonglong;
+pub type mbedtls_iso_c_forbids_empty_translation_units = crate::c_types::c_int;
pub type size_t = crate::c_types::c_uint;
pub type wchar_t = crate::c_types::c_int;
#[repr(C)]
@@ -1097,25 +979,6 @@ pub struct max_align_t {
pub __bindgen_padding_0: u64,
pub __clang_max_align_nonce2: u128,
}
-pub type intmax_t = __intmax_t;
-pub type uintmax_t = __uintmax_t;
-pub type int_least8_t = __int_least8_t;
-pub type uint_least8_t = __uint_least8_t;
-pub type int_least16_t = __int_least16_t;
-pub type uint_least16_t = __uint_least16_t;
-pub type int_least32_t = __int_least32_t;
-pub type uint_least32_t = __uint_least32_t;
-pub type int_least64_t = __int_least64_t;
-pub type uint_least64_t = __uint_least64_t;
-pub type int_fast8_t = crate::c_types::c_schar;
-pub type uint_fast8_t = crate::c_types::c_uchar;
-pub type int_fast16_t = crate::c_types::c_short;
-pub type uint_fast16_t = crate::c_types::c_ushort;
-pub type int_fast32_t = crate::c_types::c_int;
-pub type uint_fast32_t = crate::c_types::c_uint;
-pub type int_fast64_t = crate::c_types::c_longlong;
-pub type uint_fast64_t = crate::c_types::c_ulonglong;
-pub type mbedtls_iso_c_forbids_empty_translation_units = crate::c_types::c_int;
extern "C" {
#[doc = " \\brief Securely zeroize a buffer"]
#[doc = ""]
clang version 15.0.7
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
HEAD detached at 1873d3bfc
nothing to commit, working tree clean
Stable:
active toolchain
----------------
nightly-x86_64-unknown-linux-gnu (default)
rustc 1.74.0-nightly (59a829484 2023-08-30)
esp:
active toolchain
----------------
esp (overridden by +toolchain on the command line)
rustc 1.70.0-nightly (14ca5f7f5 2023-05-30) (1.70.0.0)
Seems like a mistake was made here:
In file included from /home/steve/rust/esp32c3-hw/.embuild/espressif/esp-idf/master/components/mbedtls/mbedtls/include/mbedtls/build_info.h:151,
from /home/steve/rust/esp32c3-hw/.embuild/espressif/esp-idf/master/components/mbedtls/mbedtls/library/common.h:26,
from /home/steve/rust/esp32c3-hw/.embuild/espressif/esp-idf/master/components/mbedtls/mbedtls/library/base64.c:20:
/home/steve/rust/esp32c3-hw/.embuild/espressif/esp-idf/master/components/mbedtls/mbedtls/include/mbedtls/check_config.h:414:2: error: #error "MBEDTLS_PADLOCK_C defined, but not all prerequisites"
414 | #error "MBEDTLS_PADLOCK_C defined, but not all prerequisites"
| ^~~~~
[12/856] Building C object esp-idf/mbedtls/mbedtls/library/CMakeFiles/mbedcrypto.dir/bignum_mod_raw.c.obj
FAILED: esp-idf/mbedtls/mbedtls/library/CMakeFiles/mbedcrypto.dir/bignum_mod_raw.c.obj
When setting set_debug(3)
with 3 or higher, there's a crash during the handshake for the server examples.
This has only been tested on esp32c3
because Xtensa uses a no debug build.
This happens for both async_server
and sync_server
, here's the output log for async_server
with level 3:
Waiting for connection...
Connected...
Start tls connect
INFO - 2 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls.c:3939 => handshake
INFO - 2 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_msg.c:2124 => flush output
INFO - 2 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_msg.c:2133 <= flush output
INFO - 2 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:4228 server state: 0
INFO - 2 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_msg.c:2124 => flush output
INFO - 2 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_msg.c:2133 <= flush output
INFO - 2 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:4228 server state: 1
INFO - 2 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:914 => parse client hello
INFO - 2 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_msg.c:1926 => fetch input
INFO - 2 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_msg.c:2066 in_left: 0, nb_want: 5
INFO - 2 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_msg.c:2086 in_left: 0, nb_want: 5
INFO - 2 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls.c:3950 <= handshake
INFO - 2 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls.c:3939 => handshake
INFO - 2 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_msg.c:2124 => flush output
INFO - 2 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_msg.c:2133 <= flush output
INFO - 2 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:4228 server state: 1
INFO - 2 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:914 => parse client hello
INFO - 2 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_msg.c:1926 => fetch input
INFO - 2 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_msg.c:2066 in_left: 0, nb_want: 5
INFO - 2 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_msg.c:2086 in_left: 0, nb_want: 5
INFO - 2 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_msg.c:2089 ssl->f_recv(_timeout)() returned 5 (-0xfffffffb)
0xfffffffb - _rtc_fast_bss_end
at ??:??
INFO - 2 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_msg.c:2111 <= fetch input
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:951 client hello, message type: 22
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:959 client hello, message len.: 512
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:962 client hello, protocol version: [3:1]
INFO - 2 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_msg.c:1926 => fetch input
INFO - 2 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_msg.c:2066 in_left: 5, nb_want: 517
INFO - 2 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_msg.c:2086 in_left: 5, nb_want: 517
INFO - 2 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_msg.c:2089 ssl->f_recv(_timeout)() returned 512 (-0xfffffe00)
0xfffffe00 - _rtc_fast_bss_end
at ??:??
INFO - 2 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_msg.c:2111 <= fetch input
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1048 client hello v3, handshake type: 1
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1056 client hello v3, handshake len.: 508
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1158 dumping 'client hello, version' (2 bytes)
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1158 00: 03 03 ..
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1173 dumping 'client hello, random bytes' (32 bytes)
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1173 00: ec 8d 64 08 bb 38 2c 20 79 b9 db 56 38 1a 8d fb ..d..8, y..V8...
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1173 10: 62 09 18 8e 33 63 ea 55 8e c7 5f 9f de 8d cd cb b...3c.U.._.....
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1190 dumping 'client hello, session id' (32 bytes)
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1190 00: 46 d3 37 3f fa 32 5e 7e f7 b0 8b e1 19 33 c0 bb F.7?.2^~.....3..
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1190 10: 1d 26 3e cc ff 62 4c a1 2f f6 55 f4 d2 5f 2c f7 .&>..bL./.U.._,.
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1264 dumping 'client hello, ciphersuitelist' (36 bytes)
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1264 00: 13 01 13 03 13 02 c0 2b c0 2f cc a9 cc a8 c0 2c .......+./.....,
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1264 10: c0 30 c0 0a c0 09 c0 13 c0 14 00 9c 00 9d 00 2f .0............./
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1264 20: 00 35 00 0a .5..
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1286 dumping 'client hello, compression' (1 bytes)
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1286 00: 00 .
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1315 dumping 'client hello extensions' (399 bytes)
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1315 00: 00 17 00 00 ff 01 00 01 00 00 0a 00 0e 00 0c 00 ................
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1315 10: 1d 00 17 00 18 00 19 01 00 01 01 00 0b 00 02 01 ................
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1315 20: 00 00 23 00 00 00 10 00 0e 00 0c 02 68 32 08 68 ..#.........h2.h
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1315 30: 74 74 70 2f 31 2e 31 00 05 00 05 01 00 00 00 00 ttp/1.1.........
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1315 40: 00 22 00 0a 00 08 04 03 05 03 06 03 02 03 00 33 .".............3
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1315 50: 00 6b 00 69 00 1d 00 20 da b6 7b 44 6c 93 c9 9f .k.i... ..{Dl...
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1315 60: 02 4f 58 27 cf ce c0 8e d4 5b 86 a4 35 5d f7 7e .OX'.....[..5].~
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1315 70: 83 32 48 71 26 61 aa 6d 00 17 00 41 04 bb ee d9 .2Hq&a.m...A....
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1315 80: 67 7b 73 78 01 b7 d9 a2 f0 a0 3e 67 36 ba 61 9f g{sx......>g6.a.
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1315 90: 87 70 23 66 89 01 13 11 98 0c 8f 0a eb a0 83 27 .p#f...........'
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1315 a0: c4 58 89 69 c8 7e 82 ff 0d ec 55 33 dd b7 33 5e .X.i.~....U3..3^
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1315 b0: f1 cc d7 ce cb e7 05 05 c5 57 ac 47 9e 00 2b 00 .........W.G..+.
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1315 c0: 09 08 03 04 03 03 03 02 03 01 00 0d 00 18 00 16 ................
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1315 d0: 04 03 05 03 06 03 08 04 08 05 08 06 04 01 05 01 ................
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1315 e0: 06 01 02 03 02 01 00 2d 00 02 01 01 00 1c 00 02 .......-........
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1315 f0: 40 01 00 15 00 99 00 00 00 00 00 00 00 00 00 00 @...............
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1315 100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1315 110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1315 120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1315 130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1315 140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1315 150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1315 160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1315 170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1315 180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ...............
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1441 found extended master secret extension
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1348 found renegotiation extension
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1375 found supported elliptic curves extension
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1384 found supported point formats extension
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1452 found session ticket extension
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1463 found alpn extension
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1485 unknown extension found: 5 (ignoring)
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1485 unknown extension found: 34 (ignoring)
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1485 unknown extension found: 51 (ignoring)
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1485 unknown extension found: 43 (ignoring)
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1361 found signature_algorithms extension
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1485 unknown extension found: 45 (ignoring)
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1485 unknown extension found: 28 (ignoring)
INFO - 3 /mnt/c/projects/esp/esp-mbedtls/build_mbedtls/tmpsrc/mbedtls/library/ssl_tls12_server.c:1485 unknown extension found: 21 (ignoring)
Exception 'Load access fault' mepc=0x40058e94, mtval=0x00001303
0x40058e94 - r_lld_init_evt_end_type_check_state_get
at ??:??
0x00001303 -
at ??:??
TrapFrame
PC=0x40058e94 RA/x1=0x4201562a SP/x2=0x3fc84be0 GP/x3=0x3fcca130 TP/x4=0x00000000
0x40058e94 - r_lld_init_evt_end_type_check_state_get
at ??:??
0x4201562a - core::ffi::c_str::CStr::from_ptr
at /home/anthony/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ffi/c_str.rs:296
0x3fc84be0 - __global_pointer$
at ??:??
0x3fcca130 - _heap_start
at ??:??
0x00000000 - hmac_md5_vector
at /home/bjoern/esp/esp-idf/components/wpa_supplicant/src/crypto/md5.c:107
T0/x5=0x000000df T1/x6=0x3fcca160 T2/x7=0x3c0b8044 S0/FP/x8=0x3fcca7d0 S1/x9=0x00001303
0x000000df - hmac_md5_vector
at /home/anthony/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/mod.rs:1167
0x3fcca160 - _heap_start
at ??:??
0x3c0b8044 - .Lanon.a637d6179f1be8d572ea13cf18a8161c.17
at ??:??
0x3fcca7d0 - _heap_start
at ??:??
0x00001303 -
at ??:??
A0/x10=0x00001303 A1/x11=0x3fccaa08 A2/x12=0x3fcca182 A3/x13=0x00000200 A4/x14=0x00000003
0x00001303 -
at ??:??
0x3fccaa08 - _heap_start
at ??:??
0x3fcca182 - _heap_start
at ??:??
0x00000200 - _ZN17compiler_builtins5float3div8__divdf317h5e229b8a6a8eb12dE
at ??:??
0x00000003 - hmac_md5_vector
at /home/bjoern/esp/esp-idf/components/wpa_supplicant/src/crypto/md5.c:107
A5/x15=0x00001303 A6/x16=0x000000f0 A7/x17=0x00110000 S2/x18=0x00000002 S3/x19=0x3c0b7fc4
0x00001303 -
at ??:??
0x000000f0 - hmac_md5_vector
at /home/anthony/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/bit.rs:790
0x00110000 -
at ??:??
0x00000002 - hmac_md5_vector
at /home/bjoern/esp/esp-idf/components/wpa_supplicant/src/crypto/md5.c:107
0x3c0b7fc4 - .Lanon.a637d6179f1be8d572ea13cf18a8161c.0
at ??:??
S4/x20=0x00000020 S5/x21=0x3fcca382 S6/x22=0x3fcca381 S7/x23=0x00000000 S8/x24=0x00000001
0x00000020 - hmac_md5_vector
at /home/bjoern/esp/esp-idf/components/wpa_supplicant/src/crypto/md5-internal.c:103
0x3fcca382 - _heap_start
at ??:??
0x3fcca381 - _heap_start
at ??:??
0x00000000 - hmac_md5_vector
at /home/bjoern/esp/esp-idf/components/wpa_supplicant/src/crypto/md5.c:107
0x00000001 - hmac_md5_vector
at /home/bjoern/esp/esp-idf/components/wpa_supplicant/src/crypto/md5.c:107
S9/x25=0x3c0b8028 S10/x26=0x3c0b7f28 S11/x27=0x3fcca160 T3/x28=0x00000000 T4/x29=0x00000000
0x3c0b8028 - .Lanon.a637d6179f1be8d572ea13cf18a8161c.11
at ??:??
0x3c0b7f28 - .LJTI16_0
at ??:??
0x3fcca160 - _heap_start
at ??:??
0x00000000 - hmac_md5_vector
at /home/bjoern/esp/esp-idf/components/wpa_supplicant/src/crypto/md5.c:107
0x00000000 - hmac_md5_vector
at /home/bjoern/esp/esp-idf/components/wpa_supplicant/src/crypto/md5.c:107
T5/x30=0x00000000 T6/x31=0x00000000
0x00000000 - hmac_md5_vector
at /home/bjoern/esp/esp-idf/components/wpa_supplicant/src/crypto/md5.c:107
0x00000000 - hmac_md5_vector
at /home/bjoern/esp/esp-idf/components/wpa_supplicant/src/crypto/md5.c:107
MSTATUS=0x00001881
0x00001881 -
at ??:??
MCAUSE=0x00000005
0x00000005 - hmac_md5_vector
at /home/bjoern/esp/esp-idf/components/wpa_supplicant/src/crypto/md5.c:107
MTVAL=0x00001303
0x00001303 -
at ??:??
No backtrace available - make sure to force frame-pointers. (see https://crates.io/crates/esp-backtrace)
We currently already own Certificates<'a>
for the lifetime of the session, so this should be a drop-in replacement. This would allow to re-use the same certs in multiple sessions, or with the client and the server at the same time without making unnecessary copies.
I'll paste the doc here:
X.509๐
Parsing X.509 certificates without copying the raw certificate data๐
The X.509 CRT parsing APIs
mbedtls_x509_crt_parse()
andmbedtls_x509_crt_parse_der()
create an internal copy of the raw certificate data passed to them. While this allows you to free or reuse the input buffer, it means the raw certificate data will be twice in memory at some point.To avoid that, the following API can be used to set up an X.509 certificate structure without making a copy of the input buffer:
int mbedtls_x509_crt_parse_der_nocopy( mbedtls_x509_crt *chain, const unsigned char *buf, size_t buflen );The only difference between
mbedtls_x509_crt_parse_der_nocopy()
andmbedtls_x509_crt_parse_der()
is that the buffer passed tombedtls_x509_crt_parse_der_nocopy()
holding the raw DER-encoded certificate must stay unmodified for the lifetime of the established X.509 certificate context. See the documentation for more information.Example: If your own certificate and/or the trusted CA certificates are hardcoded in ROM, you may use
mbedtls_x509_parse_der_nocopy()
to create X.509 certificate contexts from them without an additional copy in RAM.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.