Skip GCM auth on ESP8266 when no auth key is set (align with ESP32)#1214
Open
gskjold wants to merge 1 commit into
Open
Skip GCM auth on ESP8266 when no auth key is set (align with ESP32)#1214gskjold wants to merge 1 commit into
gskjold wants to merge 1 commit into
Conversation
The ESP8266 BearSSL path enforced the GCM tag whenever the frame's security byte requested authentication (authkeylen > 0), even with a blank authentication key — diverging from the ESP32/native mbedTLS paths, which gate tag verification on `authenticate` (true only when the AK has a non-zero byte). Align ESP8266 to the same rule: with a blank AK, decrypt without verifying the tag. This lets meters that use a non-standard authentication scheme (e.g. the Polish Stoen/Elgama GAMA 350, issue #1198) be read with the encryption key alone, on both platforms. Adds a native test that decodes an authenticated fixture with the AK omitted to lock the cross-platform "blank AK skips auth" contract. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🔧 PR Build ArtifactsVersion: All environments built successfully. Download the zip files:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Aligns the ESP8266 GCM path with ESP32/native: when no authentication key is configured, decrypt without verifying the GCM tag instead of failing.
Background
The ESP8266 (BearSSL) path enforced the GCM tag whenever the frame's security byte requested authentication, regardless of whether an AK was configured — it gated the tag check on
authkeylen > 0. The ESP32 and native (mbedTLS) paths instead gate onauthenticate, which is true only when the AK has a non-zero byte. So a blank AK already meant "decrypt without auth" on ESP32, but failed with-51on ESP8266.Change
One-line alignment in
GcmParser.cpp(ESP8266 branch):Why
Some meters use a non-standard authentication scheme that doesn't verify against the DLMS
SC ‖ AKAAD, so they can only be read with the encryption key. The Polish Stoen / Elgama GAMA 350 (#1198) is one such case — the reference ESPHome component decrypts with the EK only and skips authentication. This change lets such meters be read on ESP8266 the same way they already can be on ESP32 (by leaving the auth key blank). Note the ~580 B GAMA 350 telegram still realistically needs an ESP32 for buffer reasons.Testing
test_encrypted_decode_without_authkeythat decodes an authenticated fixture (issued with an AK) using the EK only / AK omitted, locking the cross-platform "blank AK skips auth" contract.The native test exercises the mbedTLS path; the ESP8266
br_gcmline is platform-gated and can't be unit-tested on host, but it now mirrors the covered ESP32/native logic.Refs #1198.