Closed GEAG closed 3 months ago
Thank you for the heads up and code, we will look into this.
Thank you for the thorough feedback. As I read it, the following commit is sufficient to remedy this specific situation: https://github.com/UtilitechAS/amsreader-firmware/commit/e575ab755c540cec450b49ff1ba0e55bc2cbbea9
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:
In both these case, GcmParser.cpp has been found to decrypt the encrypted DLMS APDU with no problem.
But in the special case that:
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:
Expected behavior The decryption should also succeed, even if no authentication key is configured, just the correct decryption key.
Screenshots irrelevant
Hardware information:
Relevant firmware information:
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.
GcmParser_cpp.txt