#3309·rustls

F11: HPKE 身份验证失败会消耗开放者序列号

作者: djc创建于 2026年9月30日更新于 2026年9月30日

Use the existing rustls/ checkout at 99f2358cae29 and a standalone sibling repro/ directory outside its Cargo workspace. Save the blocks below as repro/Cargo.toml and repro/src/main.rs; run the commands from the directory containing both rustls/ and repro/.

toml
[package]
name = "hpke-opener-check"
version = "0.0.0"
edition = "2024"

[workspace]

[dependencies]
rustls = { path = "../rustls/rustls", default-features = false }
rustls-AWS-lc-rs = { path = "../rustls/rustls-AWS-lc-rs" }
rust
use rustls_aws_lc_rs::hpke::ALL_SUPPORTED_SUITES;

fn main() {
    for suite in ALL_SUPPORTED_SUITES {
        let (public_key, private_key) = suite
            .generate_key_pair()
            .expect("generate keys");
        let (enc, mut sealer) = suite
            .setup_sealer(b"example", &public_key)
            .expect("sealer");
        let ciphertext = sealer
            .seal(b"aad", b"message 0")
            .expect("seal");
        let ciphertext_1 = sealer
            .seal(b"aad", b"message 1")
            .expect("seal");

        // Use independent contexts for the fresh control and the failed-open retry.
        let mut opener = suite
            .setup_opener(&enc, b"example", &private_key)
            .expect("opener");
        let mut control = suite
            .setup_opener(&enc, b"example", &private_key)
            .expect("control");

        // The same ciphertext and AAD authenticate with an untouched opener.
        assert_eq!(
            control
                .open(b"aad", &ciphertext)
…