Skip to content

Commit

Permalink
switch to no_std rustls
Browse files Browse the repository at this point in the history
rustls provides `Unbuffered` implementations of server and client
connections that can be used in `no_std`.

This patch implements two helper struct named `TlsServerConnection` and
`TlsClientConnection` which provide much simpler interfaces.

Crate `sys_time` is used to realize a `TimeProvider` and `rust-std-stub`
is kept to provide `io::Read` and `io::Write` traits.

Signed-off-by: Jiaqi Gao <[email protected]>
  • Loading branch information
gaojiaqi7 committed Sep 25, 2024
1 parent 68be66b commit 80dd6f9
Show file tree
Hide file tree
Showing 5 changed files with 618 additions and 103 deletions.
19 changes: 11 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ lto = true

[patch.crates-io]
ring = { path = "deps/td-shim/library/ring" }
rustls = { path = "deps/rustls/rustls" }
5 changes: 3 additions & 2 deletions src/crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ cfg-if = "1.0"
der = {version = "0.7.9", features = ["oid", "alloc", "derive"]}
pki-types = { package = "rustls-pki-types", version = "1" }
rust_std_stub = { path = "../std-support/rust-std-stub" }
rustls = { path = "../../deps/rustls/rustls", default-features = false, features = ["no_std"], optional = true }
rustls = { version = "0.23", default-features = false, features = ["ring" ], optional = true }
rustls-pemfile = { version = "2.0.0", default-features = false }
ring = { path = "../../deps/td-shim/library/ring", default-features = false, features = ["alloc"], optional = true }
ring = { path = "../../deps/td-shim/library/ring", default-features = false, features = ["alloc", "less-safe-getrandom-custom-or-rdrand"], optional = true }
sys_time = { path = "../std-support/sys_time" }
zeroize = "1.5.7"

[features]
Expand Down
3 changes: 3 additions & 0 deletions src/crypto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ pub enum Error {
/// Unable to verify the TLS peer's certificates
TlsVerifyPeerCert(String),

/// Error occurs during processing the tls connection
TlsConnection,

/// Pem certificate parsing error
DecodePemCert,

Expand Down
Loading

0 comments on commit 80dd6f9

Please sign in to comment.