Repository navigation
Description
Describe the bug
It has been found, that some DSO in Switzerland with L&G E450 SM do not only encrypt the DLMS APDU but also deliver the authentication tag appended to the encrypted APDU, while at the same time, do not provide to the customer the authentication key.
According to the encryption specification, authentication of the data issuer by an authentication tag is an optional security feature. What we have found very special is, that the DSO did not provide the customer the authentication key, even after the customer has asked the DSO multiple times for it. But the DSO delivers the authentication tag appended to the encrypted DLMS APDU with every telegram.
Our general recommendation for any DSO would be to:
- either provide the authentication key at least upon request by the customer if the DSO has append an authentication tag
- or, if they have decided, to only provide an encryption key to the customer, to not append the authentication tag at all
In both these case, GcmParser.cpp has been found to decrypt the encrypted DLMS APDU with no problem.
But in the special case that:
- the encrypted DLMS APDU is delivered by the SM CII (configured by the DSO) includes the appended authentication tag
- and the DSO does not provide the corresponding authentication key to its customer,
the code in GcmParser.cpp ov v2.2.21 fails do decrypt that encrypted DLMS APDU and only tells "decryption failed" in the debug log.
In that combination when the DLMS APDU is encrypted as well as the authentication tag appended to it, the security byte at pos 13.dec in the header of the encrypted DLMS APDU (starts with 0xDB at pos 0.dec) is set to 0x30.
To Reproduce
Steps to reproduce the behavior:
- Must have a DSO that has configured its SM to encrypt the data and append the authentication tag (security byte = 0x30).
- Do not configure the authentication key through the webUI (just the encryption key)
- Check the debug log
Expected behavior
The decryption should also succeed, even if no authentication key is configured, just the correct decryption key.
Screenshots
irrelevant
Hardware information:
- Country: [Switzerland]
- Meter: [Landis+Gyr E450]
- Encryption enabled [yes]
- AMS reader: [ESP-C3, own HW]
- M-bus adapter (irrelevant):
Relevant firmware information:
- Version: [2.2.21]
- MQTT: [irrelevant]
- MQTT payload type: [irrelevant]
- HAN GPIO: [irrelevant]
- HAN baud and parity: [2400 8E1]
- Temperature sensors [irrelevant]
- ENTSO-E API enabled: [irrelevant]
Additional context
A reworked and tested source code of GcmParser.cpp v2.2.21 will be provided by GEAG under the same AGPL license as the original v2.2.21 code. Please consult the file appended to this issue.
Activity
ArnieO commentedon Jan 21, 2024
Thank you for the heads up and code, we will look into this.
gskjold commentedon Jan 26, 2024
Thank you for the thorough feedback. As I read it, the following commit is sufficient to remedy this specific situation: e575ab7