Crates.io | embedded-mbedtls |
lib.rs | embedded-mbedtls |
version | 0.1.1 |
source | src |
created_at | 2024-08-29 09:22:49.667082 |
updated_at | 2024-09-03 14:09:37.594708 |
description | no_std Rust wrapper for Mbed TLS |
homepage | |
repository | https://git.openlogisticsfoundation.org/silicon-economy/libraries/serum/embedded-mbedtls |
max_upload_size | |
id | 1355899 |
size | 66,673 |
An Mbed TLS Rust wrapper for constrained embedded devices.
Currently, this project is developed with no_std
CoAPs and LwM2M devices in mind, though usage
is not limited to these use cases. Targeting CoAPs and LwM2M, it uses a static Mbed TLS configuration:
TLS_PSK_WITH_AES_128_CCM_8
cipher suite supportIn the future, a dynamic configuration using Rust features might be implemented, but there is currently no roadmap to do so.
embedded_nal
embedded_timers
rand_core
In addition to the following example code, also have a look at the example directory in the
git repository. Due to the strong focus on no_std
environments, the repository contains
working examples for no_std
hardware.
use embedded_mbedtls::ssl::{SslConnection, SslContext, Preset};
use nb::block;
// Assuming the variables in use contain a valid hardware abstraction and the server address
// Create the hardware context
let mut ctx = SslContext::new_udp_client_side(net_stack, clock, rng, server_addr);
// Create and configure the connection instance
let mut connection = SslConnection::new_dtls_client(&mut ctx, Preset::Default).unwrap();
connection
.configure_psk(&[1, 2, 3, 4], "embedded-mbedtls".as_bytes())
.unwrap();
// Set up connection
block!(connection.handshake()).unwrap();
// Send data
block!(connection.write("Hello, embedded-mbedtls".as_bytes())).unwrap();
// Receive data
let mut buf = [0u8; 1024];
let len = block!(connection.read(&mut buf)).unwrap();
// Close connection
block!(connection.close_notify()).unwrap();
alloc
: enables use of heap allocated contexts, see the explanation in
SslConnection
Open Logistics License
Version 1.3, January 2023
See the LICENSE file in the top-level directory.
Fraunhofer IML Embedded Rust Group - embedded-rust@iml.fraunhofer.de