mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
add a "0th order" test of ring/rustls latest API
This commit is contained in:
parent
32a8a54ec4
commit
3b6cba6174
3 changed files with 61 additions and 33 deletions
47
Cargo.lock
generated
47
Cargo.lock
generated
|
|
@ -2210,7 +2210,7 @@ dependencies = [
|
|||
"atomic-polyfill",
|
||||
"hash32 0.2.1",
|
||||
"rustc_version 0.4.0",
|
||||
"spin 0.9.8",
|
||||
"spin",
|
||||
"stable_deref_trait",
|
||||
]
|
||||
|
||||
|
|
@ -4150,21 +4150,6 @@ dependencies = [
|
|||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ring"
|
||||
version = "0.16.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
"once_cell",
|
||||
"spin 0.5.2",
|
||||
"untrusted 0.7.1",
|
||||
"web-sys",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ring"
|
||||
version = "0.17.7"
|
||||
|
|
@ -4175,7 +4160,7 @@ dependencies = [
|
|||
"libc",
|
||||
"log",
|
||||
"rkyv",
|
||||
"spin 0.9.8",
|
||||
"spin",
|
||||
"untrusted 0.9.0",
|
||||
"windows-sys 0.52.0",
|
||||
"xous 0.9.58 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
@ -4310,7 +4295,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "e87c9956bd9807afa1f77e0f7594af32566e830e088a5576d27c5b6f30f49d41"
|
||||
dependencies = [
|
||||
"log",
|
||||
"ring 0.17.7",
|
||||
"ring",
|
||||
"rustls-pki-types",
|
||||
"rustls-webpki",
|
||||
"subtle",
|
||||
|
|
@ -4329,7 +4314,7 @@ version = "0.102.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef4ca26037c909dedb327b48c3327d0ba91d3dd3c4e05dad328f210ffb68e95b"
|
||||
dependencies = [
|
||||
"ring 0.17.7",
|
||||
"ring",
|
||||
"rustls-pki-types",
|
||||
"untrusted 0.9.0",
|
||||
]
|
||||
|
|
@ -4369,12 +4354,12 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
|||
|
||||
[[package]]
|
||||
name = "sct"
|
||||
version = "0.7.0"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4"
|
||||
checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414"
|
||||
dependencies = [
|
||||
"ring 0.16.20",
|
||||
"untrusted 0.7.1",
|
||||
"ring",
|
||||
"untrusted 0.9.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -4628,9 +4613,10 @@ dependencies = [
|
|||
"rand_chacha 0.3.1",
|
||||
"rand_xorshift",
|
||||
"random-pick",
|
||||
"ring 0.17.7",
|
||||
"ring",
|
||||
"rkyv",
|
||||
"root-keys",
|
||||
"rustls",
|
||||
"sha2 0.10.8",
|
||||
"spinor",
|
||||
"threadpool",
|
||||
|
|
@ -4644,6 +4630,7 @@ dependencies = [
|
|||
"url",
|
||||
"usb-device-xous",
|
||||
"utralib 0.1.24",
|
||||
"webpki-roots",
|
||||
"x25519-dalek",
|
||||
"xous 0.9.58 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"xous-api-log",
|
||||
|
|
@ -4734,12 +4721,6 @@ dependencies = [
|
|||
"xous-api-log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
version = "0.9.8"
|
||||
|
|
@ -5164,7 +5145,7 @@ dependencies = [
|
|||
"log",
|
||||
"pem",
|
||||
"pkcs8 0.8.0",
|
||||
"ring 0.17.7",
|
||||
"ring",
|
||||
"sha2 0.10.8",
|
||||
"svd2utra 0.1.22",
|
||||
"xmas-elf",
|
||||
|
|
@ -5384,9 +5365,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
|
|||
|
||||
[[package]]
|
||||
name = "ureq"
|
||||
version = "2.9.4"
|
||||
version = "2.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "399dd89e2af196ae4f83a47bb37a1455e664fe2fed97b3ae68a1c4a3f8216e76"
|
||||
checksum = "0b52731d03d6bb2fd18289d4028aee361d6c28d44977846793b994b13cdcc64d"
|
||||
dependencies = [
|
||||
"base64 0.21.7",
|
||||
"flate2",
|
||||
|
|
|
|||
|
|
@ -85,6 +85,10 @@ url = { version = "2.3.1", optional = true }
|
|||
# note requirement for patch to xous-ring in workspace Cargo.toml
|
||||
ring = { version = "=0.17.7", optional = true }
|
||||
|
||||
# for direct TLS testing - API broke from 0.16 to 0.17 rustls
|
||||
rustls = { version = "0.22.2", optional = true }
|
||||
webpki-roots = { version = "0.26.0", optional = true }
|
||||
|
||||
# for websocket testing
|
||||
tungstenite = { version = "0.20.0", optional = true }
|
||||
|
||||
|
|
@ -148,4 +152,5 @@ mass-storage = []
|
|||
rand-api = []
|
||||
locktests = [
|
||||
] # for debugging some specific `std` tests cherry-picked out of the test suite
|
||||
simple-tls = ["rustls", "webpki-roots"]
|
||||
default = [] # "debugprint"
|
||||
|
|
|
|||
|
|
@ -561,6 +561,48 @@ impl<'a> ShellCmdApi<'a> for NetCmd {
|
|||
write!(ret, "{r}").unwrap();
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "simple-tls")]
|
||||
"rustls" => {
|
||||
use std::convert::TryInto;
|
||||
log::set_max_level(log::LevelFilter::Trace);
|
||||
log::info!("starting TLS run");
|
||||
let mut root_store = rustls::RootCertStore::empty();
|
||||
log::info!("create root store");
|
||||
root_store.extend(webpki_roots::TLS_SERVER_ROOTS.iter().cloned());
|
||||
log::info!("build TLS client config");
|
||||
let config = rustls::ClientConfig::builder()
|
||||
.with_root_certificates(root_store)
|
||||
.with_no_client_auth();
|
||||
|
||||
log::info!("point TLS to bunniefoo.com");
|
||||
let server_name = "bunniefoo.com".try_into().unwrap();
|
||||
let mut conn = rustls::ClientConnection::new(Arc::new(config), server_name).unwrap();
|
||||
|
||||
log::info!("connect TCPstream to bunniefoo.com");
|
||||
let mut sock = TcpStream::connect(("bunniefoo.com", 443)).unwrap();
|
||||
let mut tls = rustls::Stream::new(&mut conn, &mut sock);
|
||||
log::info!("create http headers and write to server");
|
||||
tls.write_all(
|
||||
concat!(
|
||||
"GET / HTTP/1.1\r\n",
|
||||
"Host: bunniefoo.com\r\n",
|
||||
"Connection: close\r\n",
|
||||
"Accept-Encoding: identity\r\n",
|
||||
"\r\n"
|
||||
)
|
||||
.as_bytes(),
|
||||
)
|
||||
.unwrap();
|
||||
log::info!("readout cipher suite");
|
||||
let ciphersuite = tls.conn.negotiated_cipher_suite().unwrap();
|
||||
log::info!("Current ciphersuite: {:?}", ciphersuite.suite());
|
||||
let mut plaintext = Vec::new();
|
||||
log::info!("read TLS response");
|
||||
tls.read_to_end(&mut plaintext).ok();
|
||||
log::info!("len: {}", plaintext.len());
|
||||
log::info!("{}", std::str::from_utf8(&plaintext).unwrap_or("utf-error"));
|
||||
log::set_max_level(log::LevelFilter::Info);
|
||||
}
|
||||
// note: to use the `shellperf` option, you need to load a version of the SOC that has the
|
||||
// performance counters built in. this can be generated using the command
|
||||
// `python3 .\betrusted_soc.py -e .\dummy.nky --perfcounter` in the betrusted-soc repo.
|
||||
|
|
|
|||
Loading…
Reference in a new issue