Repository navigation
fix(internet): the ESP read path and integrity-key warning name the protocol (#2411) - #2413
Conversation
|
Review: NEEDS CHANGES at Real blocker: Everything else checks out: all eight message prefixes correct (literal Non-blocking nits: "too short" appears twice in the trailer message; the ICV/tag messages are prefixed but not restructured into the |
|
Coverage: 91.73% -- tests failure, so this is partial (unit tier, Python 3.15,
Per-file detail: the |
…rotocol (#2411) #2366 (fixing #2297) put the house `ESP: <lowercase description>` prefix on `ESP.make`'s ProtocolError messages and on `SecurityAssociation.unavailable`, but eight sites were outside its checklist. The same condition therefore read two ways depending on the direction it was hit from -- `make` said `ESP: no security association for SPI 0x...`, `read` said `no security association for SPI 0x...`. - esp.py `ESP._read_trailer` (a staticmethod, so the prefix is spelled literally, as every `SecurityAssociation` site does): the plaintext-too-short diagnostic, the pad-length-beyond-the-plaintext one, and the padding-pattern one, which is both returned and warned with. - esp.py `ESP.read` (an instance method, so `{self.alias}:`, as `ESP.make`): the NO_SA, TRUNCATED, separate-integrity AUTH_FAILED and AEAD-tag AUTH_FAILED messages, surfaced as `esp.error`. - esp.py `SecurityAssociation.__init__`: the short-integrity-key warning. `warn` reports the caller's frame rather than the protocol, so the message text is the only thing naming ESP -- it needs the prefix more than the exceptions do, not less. - test_tier_guard.py `DependencyGateFalsifiabilityTests .test_removing_crypto_from_the_test_job_is_caught`: the new module is the second to carry a `HAS_CRYPTO` gate, so it joins that test's expected set of gated modules and its `describe_gap` location assertions. #2324 dropped this test's `len(gap.gates)` pin and kept the set equality as the structural claim, so the fix is to extend the set rather than to loosen it. Two messages were reworded rather than only prefixed, to avoid `ESP: ESP payload ...` and `ESP: decrypted ESP payload ...`, and the three that read as `<thing> for SPI x does/declares y` were turned into the `description: detail` house form. Every substring the existing tests match on is preserved. Test: tests/protocols/internet/test_esp_message_prefix_2411_unit.py (new, 13 tests, every message pinned whole rather than by substring -- matching fragments is why the omission survived #2366). Confirmed 10 failed / 3 passed against unpatched esp.py, each failure a missing prefix; the 3 that passed are the controls that assert the guards did not widen. All but one of the new tests runs without `cryptography`: an ENCR_NULL SA reaches the trailer and separate-integrity paths on hmac and hashlib alone. tests/test_tier_guard.py in full: 135 passed / 2497 subtests / 0 failed. tests/ in full, after `examples/generators/make_samples.py`: 6776 passed / 118 skipped / 101828 subtests / 0 failed. Fixes #2411.
144d27a to
d77427d
Compare
|
Review: GOOD TO GO at |
Please follow the guide below
make pylint,make mypy,make isort)make testpasses, and a test case covers the changedocs/source/changelog/and regeneratedCHANGELOG.md, if the change is user-visible — N/A, centralised in docs(changelog): shared 1.5.0 changelog — long-lived, merges last (#610, #616, #617, #618, #620) #657What is the purpose of your pull request?
fix— corrects a defectDescription of your pull request and other information
Fixes #2411.
#2366 (fixing #2297) put the house
ESP: <lowercase description>prefix onESP.make'sProtocolErrormessages and onSecurityAssociation.unavailable, but eight sites were outside its checklist. The same condition therefore read two ways depending on which direction it was hit from —makesaidESP: no security association for SPI 0x...,readsaidno security association for SPI 0x....The eight, and the text each now carries:
_read_trailer, plaintext too shortESP: decrypted payload too short: SPI 0x00004321 decrypts to 1 octets, too short to hold a pad length and next header_read_trailer, pad length beyond the plaintextESP: invalid pad length: the decrypted payload for SPI 0x00004321 declares 255 octets of padding but holds only 3; the encryption key is most likely wrong_read_trailer, padding pattern (returned and warned with)ESP: invalid padding: the decrypted payload for SPI 0x00004321 does not follow the monotonically increasing sequence of RFC 4303 s2.4ESP.read,NO_SAESP: no security association for SPI 0x00004321ESP.read,TRUNCATEDESP: payload too short: 4 octets, shorter than the 16-octet ICV the security association declaresESP.read,AUTH_FAILED(separate integrity)ESP: integrity check value does not verify for SPI 0x00004321 sequence 7ESP.read,AUTH_FAILED(AEAD tag)ESP: authentication tag does not verify for SPI 0x00004321 sequence 3; the encryption key is most likely wrongSecurityAssociation.__init__, integrity-key warningESP: invalid integrity key: AUTH_HMAC_SHA2_256_128 expects a 32-octet key, got 16 octets; the ICV will very likely fail to verify_read_traileris astaticmethod, so it spells the prefix literally, as everySecurityAssociationsite does;ESP.readis an instance method and uses{self.alias}:, asESP.makedoes.The warning is the one that needed this most:
warnreports the caller's frame rather than the protocol, so the message text is the only thing naming ESP at all.Two messages were reworded rather than only prefixed, to avoid
ESP: ESP payload ...andESP: decrypted ESP payload ...; the three reading<thing> for SPI x does/declares ywere turned into thedescription: detailhouse form. Every substring the existing tests match on is preserved.Tests.
tests/protocols/internet/test_esp_message_prefix_2411_unit.py, 13 tests, each message pinned whole rather than by substring — matching fragments is exactly why the omission survived #2366. Fail-without-fix confirmed: against unpatchedesp.py, 10 failed and 3 passed, each failure a missing prefix; the 3 that passed are the controls asserting the guards did not widen (a correct ICV still verifies, a consistent trailer is still read, a right-sized key still does not warn).tests/protocols/in full: 2033 passed / 51388 subtests / 0 failed.All but one of the new tests runs without
cryptography: anENCR_NULLSA reaches the trailer and separate-integrity paths onhmacandhashlibalone. Only the AEAD-tag case is gated onHAS_CRYPTO.