Skip to content

Commit 8c1ad4b

Browse files
jaredwolffclaude
andcommitted
Update docs, README, and changelog for PSK support
- Remove "Not supported: PSK cipher suites" from README and lib.rs - Add all 4 PSK suites to cryptography surface in README and lib.rs - Add Dtls::new_12_psk to version selection section - Add PSK client example with PskResolver to lib.rs and README - Add "psk" keyword to Cargo.toml - Add PSK entries to CHANGELOG.md under Unreleased Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2743251 commit 8c1ad4b

4 files changed

Lines changed: 83 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Unreleased
22

3+
* Add PSK (Pre-Shared Key) cipher suites for DTLS 1.2 (RFC 4279)
4+
* `PSK_AES128_CCM_8` (0xC0A8)
5+
* `PSK_AES128_GCM_SHA256` (0x00A8)
6+
* `PSK_AES256_GCM_SHA384` (0x00A9)
7+
* `PSK_CHACHA20_POLY1305_SHA256` (0xCCAB)
8+
* Add `Dtls::new_12_psk()` constructor for PSK-only sessions
9+
* Add `PskResolver` trait and PSK config builder methods
10+
* Fix client to handle optional ServerKeyExchange in PSK handshakes (RFC 4279 §2)
11+
312
# 0.4.3
413

514
* Fix server auto-sensing DTLS version with fragmented ClientHello #87

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2024"
77
license = "MIT OR Apache-2.0"
88
repository = "https://github.com/algesten/dimpl"
99
readme = "README.md"
10-
keywords = ["dtls", "tls", "webrtc"]
10+
keywords = ["dtls", "tls", "webrtc", "psk"]
1111
categories = ["network-programming", "cryptography", "security"]
1212

1313
# MSRV

README.md

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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
5055
During the handshake the engine emits
@@ -131,6 +136,38 @@ let dtls = mk_dtls_client();
131136
let _ = 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
135172
Rust 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

src/lib.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,38 @@
137137
//! # }
138138
//! ```
139139
//!
140+
//! ## Example (PSK client)
141+
//!
142+
//! ```rust,no_run
143+
//! use std::sync::Arc;
144+
//! use std::time::Instant;
145+
//!
146+
//! use dimpl::{Config, Dtls, PskResolver};
147+
//!
148+
//! struct MyPsk;
149+
//!
150+
//! impl PskResolver for MyPsk {
151+
//! fn resolve(&self, identity: &[u8]) -> Option<Vec<u8>> {
152+
//! if identity == b"device-01" {
153+
//! Some(b"shared-secret-key".to_vec())
154+
//! } else {
155+
//! None
156+
//! }
157+
//! }
158+
//! }
159+
//!
160+
//! let config = Arc::new(
161+
//! Config::builder()
162+
//! .with_psk_identity(b"device-01".to_vec())
163+
//! .with_psk_resolver(Arc::new(MyPsk))
164+
//! .build()
165+
//! .unwrap(),
166+
//! );
167+
//!
168+
//! let mut dtls = Dtls::new_12_psk(config, Instant::now());
169+
//! dtls.set_active(true); // client role
170+
//! ```
171+
//!
140172
//! ### MSRV
141173
//! Rust 1.85.0
142174
//!

0 commit comments

Comments
 (0)