1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! ADB over TLS: wireless debugging on Android 11+.
//!
//! A device with "Wireless debugging" on answers the handshake with
//! [`Command::StartTls`](crate::protocol::command::Command::StartTls)
//! instead of CNXN or AUTH, and speaks nothing but TLS 1.3 afterwards.
//! [`Connection::connect_tls`](crate::Connection::connect_tls) takes it
//! up on that. This module holds the certificate and the `rustls`
//! profile the host presents; the transport that runs TLS is
//! [`MaybeTls`](crate::transport::tls::MaybeTls).
//!
//! # Connecting
//!
//! ```ignore
//! use libadb::keys::rsa::rand_core::OsRng;
//! use libadb::transport::tls::MaybeTls;
//! use libadb::{
//! Connection, ConnectionConfig, Feature, HostBanner, TlsClientConfig, TlsIdentity, TokioTcp,
//! };
//!
//! // Once per key: building the identity signs a certificate.
//! let identity = TlsIdentity::from_key(&key, &mut OsRng)?;
//! let tls = TlsClientConfig::adb(&identity)?;
//!
//! let tcp = tokio::net::TcpStream::connect(addr).await?;
//! let transport = MaybeTls::plain(TokioTcp::new(tcp));
//! let conn = Connection::connect_tls(
//! transport,
//! key,
//! HostBanner::Features(&[Feature::ShellV2]),
//! ConnectionConfig::new(),
//! &tls,
//! )
//! .await?;
//! ```
//!
//! # What authenticates whom
//!
//! The device authenticates the host by the public key inside the
//! client certificate, checked against the same trusted-key store a USB
//! authorisation prompt fills. A key that was confirmed over USB is
//! therefore accepted here with no pairing at all.
//!
//! The host does not authenticate the device. Its certificate is
//! self-signed and belongs to no chain, and `adb` accepts whatever it
//! is handed; [`TlsClientConfig::adb`] does the same. What stands in
//! for it is the device's position on the network and the ADB layer
//! above. If that is not enough for you, build your own verifier and
//! pass it through [`TlsClientConfig::from_rustls`].
//!
//! # Elsewhere, and not covered
//!
//! * `adb pair`, which puts a *new* key on a device, lives in
//! `crate::pairing` behind the `pairing` feature. A key the device
//! already trusts does not need it.
//! * Finding the port. Wireless debugging picks a fresh one every time
//! it is switched on and announces it over DNS-SD; this crate does no
//! service discovery, so the caller supplies host and port.
//! * TLS over USB: adbd never offers STLS there. `connect_tls` still
//! serves a USB transport, through the plain handshake.
pub use ;
pub use ;
pub use rustls;