Commit 99f24f5
committed
Stop advertising the unimplementable AES-GCM suites
The AES-GCM symmetric suites were advertised but could never be used.
bitcoin-hpke removed its AES-GCM schemes in 0.13.0, and `dispatch_hpkes_new!`
only ever mapped ChaCha20Poly1305, so a peer that honoured the advertisement
and selected AES-GCM got `Err(InvalidKeyType)`. `Config::supported()` returned
true for it anyway, and the test constants listed it first, which is why 11 of
this crate's own tests failed. Correcting `supported()` makes
`strip_unsupported` prune the advertised KeyConfig automatically. The `Aead`
enum keeps its GCM variants so other peers' configs still parse.
`decode` built its probe config with `Aes128Gcm` on the grounds that "the KDF
and AEAD doesn't matter here"; it does now, since the probe is checked against
`supported()`, so it uses ChaCha20Poly1305.
`decode` also rejects a config whose suite list is empty after pruning, with
`Error::Unsupported`. Without that, a client handed a GCM-only config reached
`ClientRequest::from_config`, which selects `symmetric[0]`, and panicked on the
empty list where `main` returned `InvalidKeyType`. `decode_list` already skips
`Unsupported` entries, so a list containing such a config decodes to the usable
remainder. A test covers both paths. The example server no longer requests
AES-128-GCM, which it would only have had stripped.
Two tests were stale from before the secp256k1 port and never passed:
`derive_key_pair`'s expected config encoded a 32-byte X25519 key under KEM
0x0020, regenerated here for KEM 0x0016 with a 65-byte key; and
`truncate_kdf_aead_list` hard-coded an offset that assumed the X25519 key size,
so it now derives the offset from the encoding.
Also fixes two lints current clippy rejects under this crate's
`deny(warnings, clippy::pedantic)`: a redundant `continue` and non-inlined
format args.1 parent ba508f8 commit 99f24f5
4 files changed
Lines changed: 59 additions & 32 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
| 111 | + | |
115 | 112 | | |
116 | 113 | | |
117 | 114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
184 | | - | |
185 | | - | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
186 | 187 | | |
187 | 188 | | |
188 | 189 | | |
| |||
210 | 211 | | |
211 | 212 | | |
212 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
213 | 220 | | |
214 | 221 | | |
215 | 222 | | |
| |||
241 | 248 | | |
242 | 249 | | |
243 | 250 | | |
244 | | - | |
| 251 | + | |
245 | 252 | | |
246 | 253 | | |
247 | 254 | | |
| |||
278 | 285 | | |
279 | 286 | | |
280 | 287 | | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
| 288 | + | |
| 289 | + | |
285 | 290 | | |
286 | 291 | | |
287 | 292 | | |
| |||
364 | 369 | | |
365 | 370 | | |
366 | 371 | | |
367 | | - | |
| 372 | + | |
368 | 373 | | |
369 | 374 | | |
370 | 375 | | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
375 | 408 | | |
376 | 409 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
323 | 323 | | |
324 | 324 | | |
325 | 325 | | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
| 326 | + | |
| 327 | + | |
330 | 328 | | |
331 | 329 | | |
332 | 330 | | |
| |||
473 | 471 | | |
474 | 472 | | |
475 | 473 | | |
| 474 | + | |
| 475 | + | |
476 | 476 | | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
481 | 483 | | |
482 | 484 | | |
483 | 485 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
401 | 401 | | |
402 | 402 | | |
403 | 403 | | |
404 | | - | |
| 404 | + | |
405 | 405 | | |
406 | 406 | | |
407 | 407 | | |
| |||
413 | 413 | | |
414 | 414 | | |
415 | 415 | | |
416 | | - | |
| 416 | + | |
417 | 417 | | |
418 | 418 | | |
419 | 419 | | |
| |||
462 | 462 | | |
463 | 463 | | |
464 | 464 | | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | 465 | | |
471 | 466 | | |
472 | 467 | | |
| |||
0 commit comments