@@ -22,8 +22,9 @@ verification and SRTP key export yourself.
2222
2323### Version selection
2424
25- Three constructors control which DTLS version is used:
26- - [ ` Dtls::new_12 ` ] [ new_12 ] — explicit DTLS 1.2
25+ Four constructors control which DTLS version is used:
26+ - [ ` Dtls::new_12 ` ] [ new_12 ] — explicit DTLS 1.2 (certificate‑based)
27+ - [ ` Dtls::new_12_psk ` ] [ new_12_psk ] — explicit DTLS 1.2 (PSK, no certificates)
2728- [ ` Dtls::new_13 ` ] [ new_13 ] — explicit DTLS 1.3
2829- [ ` Dtls::new_auto ` ] [ new_auto ] — auto‑sense: the first
2930 incoming ClientHello determines the version (based on the
@@ -34,6 +35,11 @@ Three constructors control which DTLS version is used:
3435 - ` ECDHE_ECDSA_AES256_GCM_SHA384 `
3536 - ` ECDHE_ECDSA_AES128_GCM_SHA256 `
3637 - ` ECDHE_ECDSA_CHACHA20_POLY1305_SHA256 `
38+ - ** PSK cipher suites (TLS 1.2 over DTLS)**
39+ - ` PSK_AES128_CCM_8 `
40+ - ` PSK_AES128_GCM_SHA256 `
41+ - ` PSK_AES256_GCM_SHA384 `
42+ - ` PSK_CHACHA20_POLY1305_SHA256 `
3743- ** Cipher suites (TLS 1.3 over DTLS)**
3844 - ` TLS_AES_128_GCM_SHA256 `
3945 - ` TLS_AES_256_GCM_SHA384 `
@@ -44,7 +50,6 @@ Three constructors control which DTLS version is used:
4450- ** DTLS‑SRTP** : Exports keying material for ` SRTP_AEAD_AES_256_GCM ` ,
4551 ` SRTP_AEAD_AES_128_GCM ` , and ` SRTP_AES128_CM_SHA1_80 ` ([ RFC 5764] , [ RFC 7714] ).
4652- ** Extended Master Secret** ([ RFC 7627] ) is negotiated and enforced (DTLS 1.2).
47- - Not supported: PSK cipher suites.
4853
4954### Certificate model
5055During the handshake the engine emits
@@ -131,6 +136,38 @@ let dtls = mk_dtls_client();
131136let _ = example_event_loop (dtls );
132137```
133138
139+ ## Example (PSK client)
140+
141+ ``` rust
142+ use std :: sync :: Arc ;
143+ use std :: time :: Instant ;
144+
145+ use dimpl :: {Config , Dtls , PskResolver };
146+
147+ struct MyPsk ;
148+
149+ impl PskResolver for MyPsk {
150+ fn resolve (& self , identity : & [u8 ]) -> Option <Vec <u8 >> {
151+ if identity == b " device-01" {
152+ Some (b " shared-secret-key" . to_vec ())
153+ } else {
154+ None
155+ }
156+ }
157+ }
158+
159+ let config = Arc :: new (
160+ Config :: builder ()
161+ . with_psk_identity (b " device-01" . to_vec ())
162+ . with_psk_resolver (Arc :: new (MyPsk ))
163+ . build ()
164+ . unwrap (),
165+ );
166+
167+ let mut dtls = Dtls :: new_12_psk (config , Instant :: now ());
168+ dtls . set_active (true ); // client role
169+ ```
170+
134171#### MSRV
135172Rust 1.85.0
136173
@@ -139,6 +176,7 @@ Rust 1.85.0
139176- Renegotiation is not implemented (WebRTC does full restart).
140177
141178[ new_12 ] : https://docs.rs/dimpl/latest/dimpl/struct.Dtls.html#method.new_12
179+ [ new_12_psk ] : https://docs.rs/dimpl/latest/dimpl/struct.Dtls.html#method.new_12_psk
142180[ new_13 ] : https://docs.rs/dimpl/latest/dimpl/struct.Dtls.html#method.new_13
143181[ new_auto ] : https://docs.rs/dimpl/latest/dimpl/struct.Dtls.html#method.new_auto
144182[ peer_cert ] : https://docs.rs/dimpl/latest/dimpl/enum.Output.html#variant.PeerCert
0 commit comments