Skip to content

Commit

Permalink
feat: update to use stable rust
Browse files Browse the repository at this point in the history
  • Loading branch information
lulf committed Jan 6, 2024
1 parent 4acc04f commit dcef484
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 64 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## 0.17.0 - 2024-01-06

- Update to stable rust

## 0.16.3 - 2023-11-04

- Don't block when reading into an empty buffer
Expand Down
9 changes: 4 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "embedded-tls"
version = "0.16.3"
version = "0.17.0"
edition = "2021"
description = "TLS 1.3 client with no_std support and no allocator"
documentation = "https://docs.rs/embedded-tls"
Expand All @@ -24,7 +24,7 @@ typenum = { version = "1.15.0", default-features = false }
heapless = { version = "0.8", default-features = false }
heapless_typenum = { package = "heapless", version = "0.6", default-features = false }
embedded-io = "0.6"
embedded-io-async = { version = "0.6", optional = true }
embedded-io-async = "0.6"
embedded-io-adapters = { version = "0.6", optional = true }
generic-array = { version = "0.14", default-features = false }
webpki = { package = "rustls-webpki", version = "0.101.7", default-features = false, optional = true }
Expand All @@ -35,7 +35,7 @@ defmt = { version = "0.3", optional = true }

[dev-dependencies]
env_logger = "0.10"
tokio = { version = "1.7", features = ["full"] }
tokio = { version = "1", features = ["full"] }
mio = { version = "0.8.3", features = ["os-poll", "net"] }
rustls = "0.21.6"
rustls-pemfile = "1.0"
Expand All @@ -46,9 +46,8 @@ pem-parser = "0.1.1"
openssl = "0.10.44"

[features]
default = ["std", "async", "log", "tokio"]
default = ["std", "log", "tokio"]
defmt = ["dep:defmt", "embedded-io/defmt-03", "heapless/defmt-03"]
std = ["embedded-io/std", "embedded-io-async/std"]
tokio = ["embedded-io-adapters/tokio-1"]
async = ["embedded-io-async"]
alloc = []
26 changes: 13 additions & 13 deletions examples/embassy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@ edition = "2021"
resolver = "2"

[dependencies]
embedded-tls = { path = "../..", features = ["async", "alloc", "std", "log"], default-features = false }
embedded-tls = { path = "../..", features = ["alloc", "std", "log"], default-features = false }
env_logger = "0.10"
rand = "0.8"
log = "0.4"
static_cell = { version = "1", features = ["nightly"] }
embassy-executor = { version = "0.1.0", default-features = false, features = ["std", "log", "integrated-timers", "nightly"] }
embassy-time = { version = "0.1.0", default-features = false, features = ["std"] }
smoltcp = { version = "0.10.0", features = ["dns-max-server-count-4"] }
embassy-net = { version = "0.1.0", features=[ "std", "nightly", "log", "medium-ethernet", "medium-ip", "tcp", "udp", "dns", "dhcpv4", "proto-ipv6"] }
static_cell = "1"
embassy-executor = { version = "0.4", features = ["task-arena-size-32768", "arch-std", "executor-thread", "log", "integrated-timers"] }
embassy-time = { version = "0.2", default-features = false, features = ["std"] }
smoltcp = { version = "0.11.0", features = ["dns-max-server-count-4"] }
embassy-net = { version = "0.3.0", features=[ "std", "log", "medium-ethernet", "medium-ip", "tcp", "udp", "dns", "dhcpv4", "proto-ipv6"] }
embassy-net-tuntap = { version = "0.1.0" }

async-io = "1.6.0"
futures = { version = "0.3.17" }
libc = "0.2.101"
clap = { version = "3.0", features = ["derive", "color"] }
heapless = { version = "0.7.5", default-features = false }
embedded-io-async = { version = "0.6.0" }
embedded-io-adapters = { version = "0.6.0", features = ["futures-03"] }
heapless = { version = "0.8", default-features = false }
embedded-io-async = { version = "0.6" }
embedded-io-adapters = { version = "0.6", features = ["futures-03"] }
critical-section = { version = "1.1", features = ["std"] }

[patch.crates-io]
embassy-executor = { git = "https://github.com/embassy-rs/embassy.git", rev = "59f706ee2f93252d1c040cea149dfd744f4d8c16" }
embassy-net = { git = "https://github.com/embassy-rs/embassy.git", rev = "59f706ee2f93252d1c040cea149dfd744f4d8c16" }
embassy-net-tuntap = { git = "https://github.com/embassy-rs/embassy.git", rev = "59f706ee2f93252d1c040cea149dfd744f4d8c16" }
embassy-time = { git = "https://github.com/embassy-rs/embassy.git", rev = "59f706ee2f93252d1c040cea149dfd744f4d8c16" }
embassy-executor = { git = "https://github.com/embassy-rs/embassy.git", rev = "51de518bd3edf15ffc76a55b6d003a633556ae56" }
embassy-net = { git = "https://github.com/embassy-rs/embassy.git", rev = "51de518bd3edf15ffc76a55b6d003a633556ae56" }
embassy-net-tuntap = { git = "https://github.com/embassy-rs/embassy.git", rev = "51de518bd3edf15ffc76a55b6d003a633556ae56" }
embassy-time = { git = "https://github.com/embassy-rs/embassy.git", rev = "51de518bd3edf15ffc76a55b6d003a633556ae56" }
12 changes: 5 additions & 7 deletions examples/embassy/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#![allow(incomplete_features)]
#![feature(type_alias_impl_trait)]
#![feature(async_fn_in_trait)]

use clap::Parser;
use embassy_executor::{Executor, Spawner};
use embassy_net::tcp::TcpSocket;
Expand All @@ -13,7 +9,7 @@ use embedded_tls::{Aes128GcmSha256, NoVerify, TlsConfig, TlsConnection, TlsConte
use heapless::Vec;
use log::*;
use rand::{rngs::OsRng, RngCore};
use static_cell::{make_static, StaticCell};
use static_cell::StaticCell;

#[derive(Parser)]
#[clap(version = "1.0")]
Expand Down Expand Up @@ -55,10 +51,12 @@ async fn main_task(spawner: Spawner) {
let seed = u64::from_le_bytes(seed);

// Init network stack
let stack = &*make_static!(Stack::new(
static STACK: StaticCell<Stack<TunTapDevice>> = StaticCell::new();
static RESOURCES: StaticCell<StackResources<3>> = StaticCell::new();
let stack = &*STACK.init(Stack::new(
device,
config,
make_static!(StackResources::<3>::new()),
RESOURCES.init(StackResources::<3>::new()),
seed
));

Expand Down
6 changes: 3 additions & 3 deletions examples/tokio-psk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ edition = "2021"

[dependencies]
embedded-tls = { path = "../..", features = ["log", "tokio"] }
embedded-io-adapters = { version = "0.6.0", features = ["tokio-1"] }
embedded-io-async = "0.6.0"
embedded-io-adapters = { version = "0.6", features = ["tokio-1"] }
embedded-io-async = "0.6"
env_logger = "0.10"
tokio = { version = "1.7", features = ["full"] }
tokio = { version = "1", features = ["full"] }
rand = "0.8"
log = "0.4"
pem-parser = "0.1.1"
6 changes: 3 additions & 3 deletions examples/tokio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ authors = [

[dependencies]
embedded-tls = { path = "../..", features = ["log", "tokio"] }
embedded-io-adapters = { version = "0.6.0", features = ["tokio-1"] }
embedded-io-async = "0.6.0"
embedded-io-adapters = { version = "0.6", features = ["tokio-1"] }
embedded-io-async = "0.6"
env_logger = "0.10"
tokio = { version = "1.7", features = ["full"] }
tokio = { version = "1", features = ["full"] }
rand = "0.8"
log = "0.4"
pem-parser = "0.1.1"
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Before upgrading check that everything is available on all tier1 targets here:
# https://rust-lang.github.io/rustup-components-history
[toolchain]
channel = "nightly-2023-10-02"
channel = "1.75"
components = [ "rustfmt" ]
targets = [ "thumbv7em-none-eabi" ]
8 changes: 1 addition & 7 deletions src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@ use crate::{
};
use core::fmt::Debug;
use embedded_io::Error as _;
use rand_core::{CryptoRng, RngCore};

use embedded_io::{Read as BlockingRead, Write as BlockingWrite};

#[cfg(feature = "async")]
use embedded_io_async::{Read as AsyncRead, Write as AsyncWrite};
use rand_core::{CryptoRng, RngCore};

use crate::application_data::ApplicationData;
// use crate::handshake::certificate_request::CertificateRequest;
Expand Down Expand Up @@ -179,7 +176,6 @@ pub enum State {
}

impl<'a> State {
#[cfg(feature = "async")]
#[allow(clippy::too_many_arguments)]
pub async fn process<'v, Transport, CipherSuite, RNG, Verifier>(
self,
Expand Down Expand Up @@ -341,7 +337,6 @@ where
Ok(())
}

#[cfg(feature = "async")]
async fn handle_processing_error<'a, CipherSuite>(
result: Result<State, TlsError>,
transport: &mut impl AsyncWrite,
Expand All @@ -365,7 +360,6 @@ where
result
}

#[cfg(feature = "async")]
async fn respond<CipherSuite>(
tx: &[u8],
transport: &mut impl AsyncWrite,
Expand Down
14 changes: 1 addition & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
#![cfg_attr(not(any(test, feature = "std")), no_std)]
#![allow(dead_code)]
#![cfg_attr(
feature = "async",
allow(stable_features, incomplete_features, unknown_lints, async_fn_in_trait)
)]
#![cfg_attr(feature = "async", feature(impl_trait_projections, async_fn_in_trait))]

//! Embedded-TLS is a Rust-native TLS 1.3 implementation that works in a no-std environment. The
//! implementation is work in progress, but the [example clients](https://github.com/drogue-iot/embedded-tls/tree/main/examples) should work against the [rustls](https://github.com/ctz/rustls) echo server.
//!
//! The client supports both async and blocking modes. By default, the `async` and `std` features are enabled. The `async` feature requires Rust nightly, while the blocking feature works on Rust stable.
//! The client supports both async and blocking modes. By default, the `std` feature is enabled, but can be disabled for bare metal usage.
//!
//! To use the async mode, import `embedded_tls::*`. To use the blocking mode, import `embedded_tls::blocking::*`.
//!
Expand Down Expand Up @@ -86,10 +80,7 @@ mod write_buffer;
#[cfg(feature = "webpki")]
pub mod webpki;

#[cfg(feature = "async")]
mod asynch;

#[cfg(feature = "async")]
pub use asynch::*;

#[derive(Debug, Copy, Clone)]
Expand Down Expand Up @@ -157,6 +148,3 @@ mod stdlib {
}
}
}

#[cfg(feature = "std")]
pub use stdlib::*;
4 changes: 0 additions & 4 deletions src/record_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ use core::marker::PhantomData;

use crate::key_schedule::ReadKeySchedule;
use embedded_io::{Error, Read as BlockingRead};

#[cfg(feature = "async")]
use embedded_io_async::Read as AsyncRead;

use crate::{
Expand Down Expand Up @@ -40,7 +38,6 @@ where
}
}

#[cfg(feature = "async")]
pub async fn read<'m>(
&'m mut self,
transport: &mut impl AsyncRead,
Expand All @@ -59,7 +56,6 @@ where
ServerRecord::decode(header, data, key_schedule.transcript_hash())
}

#[cfg(feature = "async")]
async fn advance<'m>(
&'m mut self,
transport: &mut impl AsyncRead,
Expand Down
2 changes: 0 additions & 2 deletions tests/client_test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#![macro_use]
#![allow(incomplete_features)]
#![feature(async_fn_in_trait)]
use embedded_io::BufRead as _;
use embedded_io_adapters::{std::FromStd, tokio_1::FromTokio};
use embedded_io_async::BufRead as _;
Expand Down
2 changes: 0 additions & 2 deletions tests/early_data_test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#![macro_use]
#![allow(incomplete_features)]
#![feature(async_fn_in_trait)]
use embedded_io::{Read, Write};
use embedded_io_adapters::std::FromStd;
use rand_core::OsRng;
Expand Down
2 changes: 0 additions & 2 deletions tests/psk_test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#![macro_use]
#![allow(incomplete_features)]
#![feature(async_fn_in_trait)]
use embedded_io_adapters::tokio_1::FromTokio;
use embedded_tls::*;
use openssl::ssl;
Expand Down
2 changes: 0 additions & 2 deletions tests/split_test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#![macro_use]
#![allow(incomplete_features)]
#![feature(async_fn_in_trait)]
use embedded_io::{Read, Write};
use embedded_io_adapters::std::FromStd;
use rand_core::OsRng;
Expand Down

0 comments on commit dcef484

Please sign in to comment.