Commit 4825f92
Add DTLS 1.2 PSK authentication (RFC 4279)
Adds pre-shared key support with TLS_PSK_WITH_AES_128_CCM_8 (0xC0A8),
the cipher mandated by RFC 7925 / LwM2M for constrained IoT devices.
Public API:
- Psk enum (Client { identity, resolver } / Server { hint, resolver })
- PskResolver trait for callback-based key lookup
- ConfigBuilder::with_psk_client / with_psk_server
- Dtls::new_12_psk constructor for PSK-only sessions
- Error::PskError variant
Internals:
- AuthMode enum unifies Certificate and PSK paths in CryptoContext
- ccm_cipher module implements AES-128-CCM-8 AEAD
- ClientKeyExchange / ServerKeyExchange gain PSK variants
- PSK cipher suite wired into both aws-lc-rs and rust-crypto backends
- Client handles servers that omit ServerKeyExchange when no identity
hint is present (RFC 4279 §2)
Config validation:
- Reject PSK configs where DTLS 1.2 has no PSK suite after filtering,
regardless of DTLS 1.3 state (DTLS 1.3 is not a fallback for
Dtls::new_12_psk, and DTLS 1.3 PSK is a separate mechanism)
- Require kx groups whenever a cert-based DTLS 1.2 suite survives the
filter, even when PSK is also configured
- require_client_certificate documented as cert-only
Security:
- Certificate-mode contexts reject PSK suites, preventing downgrade
past Certificate/CertificateVerify
- PSK suites filtered from advertised list when no resolver configured
- Invalid-identity handling uses a dummy-PSK fallback plus an explicit
psk_valid flag to avoid a timing oracle that would otherwise leak
identity validity
- CCM_8 ordered after AEAD suites in the default list
Tests:
- tests/dtls12/psk.rs covers the PSK handshake and edge cases
- Config-builder validation tests for PSK + DTLS 1.3, PSK + cert
suites, and PSK-only empty-kx-groups cases
- OpenSSL interop tests included but #[ignore]d (OpenSSL excludes
CCM-8 from DTLS)
Docs: README, CHANGELOG, and module docs updated.
Signed-off-by: Jared Wolff <hello@jaredwolff.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 6b60a94 commit 4825f92
27 files changed
Lines changed: 2040 additions & 200 deletions
File tree
- src
- crypto
- aws_lc_rs
- rust_crypto
- validation
- dtls12
- message
- tests
- dtls12
- ossl
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
3 | 8 | | |
4 | 9 | | |
5 | 10 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| 72 | + | |
| 73 | + | |
71 | 74 | | |
72 | 75 | | |
73 | 76 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| 38 | + | |
| 39 | + | |
37 | 40 | | |
38 | 41 | | |
39 | 42 | | |
| |||
44 | 47 | | |
45 | 48 | | |
46 | 49 | | |
47 | | - | |
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
| |||
131 | 133 | | |
132 | 134 | | |
133 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
134 | 167 | | |
135 | 168 | | |
136 | 169 | | |
| |||
139 | 172 | | |
140 | 173 | | |
141 | 174 | | |
| 175 | + | |
142 | 176 | | |
143 | 177 | | |
144 | 178 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
| 108 | + | |
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| |||
0 commit comments