Hello Mikko,
Trying to connect with meter using different security settings.
Connection is ok with None, Encryption, AuthenticationEncryption.
Can't connect with Security=Authentication.
Block Cipher Key, Authentication key, Broadcast Key values are set in Device Properties - Secured Connections Tab and Security Setup object via "Update Key" button.
Using "Suite0" Security suite.
Could you give me a hint, please?
Here is exchange log:
16:45:48 Send SNRM request.
TX: 7E A0 08 02 23 61 93 DB 22 7E
16:45:48
RX: 7E A0 08 61 02 23 73 CD 55 7E
16:45:48 Send AARQ request.
TX: 7E A0 6C 02 23 61 10 EB 18 E6 E6 00 60 5D A1 09 06 07 60 85 74 05 08 01 03 A6 0A 04 08 68 6F 6D 65 30 31 32 33 8A 02 07 80 8B 07 60 85 74 05 08 02 02 AC 12 80 10 04 73 5D 3C 3F 15 64 28 20 1B 21 59 2D 3C 33 4A BE 23 04 21 21 1F 10 00 00 00 00 01 00 00 00 06 5F 1F 04 00 62 1E 5D FF FF 53 C0 5D 0B 09 58 19 AB 89 00 AB D4 01 6E 7E
16:45:48
RX: 7E A0 6B 61 02 23 30 2D 99 E6 E7 00 61 5C A1 09 06 07 60 85 74 05 08 01 03 A2 03 02 01 00 A3 05 A1 03 02 01 0E A4 0A 04 08 52 41 4F 32 34 30 36 30 AA 12 80 10 50 C1 58 06 EF 2E 44 92 7A 18 BB 42 B6 55 74 B5 BE 23 04 21 28 1F 10 00 00 00 00 08 00 06 5F 1F 04 00 00 1A 1D 03 E8 00 07 A6 DB 94 29 2E A3 20 EE 7A E5 C3 0B A1 6C 7E
16:45:48
RX: 7E A0 08 61 02 23 73 CD 55 7E
Best regards, Andrew
Hi Andrew, Can you read the…
Hi Andrew,
Can you read the security setup object? Check the policy attribute. It defines what authentication level you need to use. If you use another, the connection fails.
The correct settings should be in the meter manufacturer's documents and you should use them. I don't know what the meter manufacturer has implemented and what the meter expects. The reason for this can be anything.
BR,
Mikko
Yes, security setup object…
Yes, security setup object is r/w, so before connection attempt with Security=Authentication option I'm setting Security policy = Authenticated in Security Setup object.
Just a little bit more details:
1) Device setting->Authentication field in "High" selection. Should it work in theory? Or should I use HighGmac while using Security=Authentication?
2) Device Settings - Secured connection->Invocation Counter field in unchecked state, filled with zero value. Is it ok or should I type in LN OBIS code?
Best regards, Andrew.
Hi, Authentication tells you…
Hi,
Authentication tells you what access rights you have for the meter, and security tells you how messages are encrypted.
1. Only the manufacturer will know how this is implemented. You need to ask this from the manufacturer.
2. Set the OBIS code if the meter returns an encryption error when establishing the connection to the meter.
Each DLMS meter is different and answers to your questions should be in the meter documentation.
BR,
Mikko
Hello Mikko, just a little…
Hello Mikko,
just a little bit more investigation based on source code debug:
1) Security=Authentication goes ok from python code.
2)Security=Authentication went wrong from Director. In fact, there is an exception in TagsEquals(byte[] tag1, byte[] tag2) because of NULL value for tag2 (p.CountTag) in C# code. tag2 is not None in python, so it works good.
So this exception goes up and finally ends with a message of rejected connection.
Best regards, Andrew.
Hi, The authentication tag…
Hi,
The authentication tag must exist if you have selected the authentication security level.
Can you share the hex log so I can check this from the bytes?
BR,
Mikko
Hi Mikko, first log from…
Hi Mikko,
first log from python output window:
Loaded '__main__'
Loaded 'runpy'
Authentication: Authentication.HIGH
ClientAddress: 0x30
ServerAddress: 0x91
Standard: Standard.DLMS
Security: Security.AUTHENTICATION
System title: 62 69 62 61 62 6F 62 61
Authentication key: 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 30
Block cipher key: 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31
Loaded 'GXDLMSReader'
TX: 14:24:51 7E A0 08 02 23 61 93 DB 22 7E
RX: 14:24:51 7E A0 08 61 02 23 73 CD 55 7E
Loaded 'gurux_dlms.GXDLMSClient'
TX: 14:24:53 7E A0 6C 02 23 61 10 EB 18 E6 E6 00 60 5D A1 09 06 07 60 85 74 05 08 01 03 A6 0A 04 08 62 69 62 61 62 6F 62 61 8A 02 07 80 8B 07 60 85 74 05 08 02 02 AC 12 80 10 90 E5 EE 5A ED 43 F7 0A 00 F4 59 80 9F C6 09 11 BE 23 04 21 21 1F 10 00 00 00 01 01 00 00 00 06 5F 1F 04 00 40 1E 5D FF FF 5E 6D 54 FB 31 DD 2E BA 21 CD A5 F9 C2 D8 7E
RX: 14:24:53 7E A0 6B 61 02 23 30 2D 99 E6 E7 00 61 5C A1 09 06 07 60 85 74 05 08 01 03 A2 03 02 01 00 A3 05 A1 03 02 01 0E A4 0A 04 08 52 41 4F 32 34 30 36 30 AA 12 80 10 7A 96 09 2C A5 57 74 64 C4 AF 15 28 A4 E9 57 DB BE 23 04 21 28 1F 10 00 00 00 01 08 00 06 5F 1F 04 00 00 1A 1D 03 E8 00 07 AD 9C C2 89 D9 91 22 5D E7 F3 91 49 A0 AF 7E
Loaded 'gurux_dlms.GXDLMSChippering'
Loaded 'gurux_dlms.GXCiphering'
Loaded 'gurux_dlms._GXAPDU'
Decrypted PDU: C3 01 C1 00 0F 00 00 28 00 00 FF 01 01 09 10 0E A9 1F 1B 01 25 22 2A A5 57 67 00 3D EE 93 3F
<ActionRequest>
<ActionRequestNormal>
<InvokeIdAndPriority Value="C1" />
<MethodDescriptor>
<ClassId Value="000F" />
<InstanceId Value="0000280000FF" />
<MethodId Value="01" />
</MethodDescriptor>
<MethodInvocationParameters>
<OctetString Value="0EA91F1B0125222AA55767003DEE933F" />
</MethodInvocationParameters>
</ActionRequestNormal>
</ActionRequest>
TX: 14:25:10 7E A0 3F 02 23 61 32 55 72 E6 E6 00 CB 30 10 00 00 00 02 C3 01 C1 00 0F 00 00 28 00 00 FF 01 01 09 10 0E A9 1F 1B 01 25 22 2A A5 57 67 00 3D EE 93 3F F5 4C 52 C4 9D 3F 55 3C 89 02 22 8D C3 F5 7E
Loaded 'gurux_dlms.GXDLMS'
Decrypted PDU: C7 01 C1 00 01 00 09 10 CA D0 38 BF 97 30 A5 D5 B0 DA AB E1 1E BC 63 87
<ActionResponse>
<ActionResponseNormal>
<InvokeIdAndPriority Value="C1" />
<Result Value="Success" />
<ReturnParameters>
<Data>
<OctetString Value="CAD038BF9730A5D5B0DAABE11EBC6387" />
</Data>
</ReturnParameters>
</ActionResponseNormal>
</ActionResponse>
RX: 14:25:18 7E A0 38 61 02 23 52 97 B1 E6 E7 00 CF 29 10 00 00 00 02 C7 01 C1 00 01 00 09 10 CA D0 38 BF 97 30 A5 D5 B0 DA AB E1 1E BC 63 87 FC 1D 16 5C 6B 76 89 8A 22 F1 09 36 E4 C3 7E
Second log from Director output window (VS):
14:34:03 Initializing serial connection.
14:34:08 Send SNRM request.
7E A0 08 02 23 61 93 DB 22 7E
14:34:08
7E A0 08 61 02 23 73 CD 55 7E
14:34:08 Parsing UA reply succeeded.
Encrypt settings: Security: Authentication Invocation Counter: 0 SystemTitle: 62 69 62 61 62 6F 62 61 AuthenticationKey: 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 30 BlockCipherKey: 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31
14:34:13 Send AARQ request.
7E A0 6C 02 23 61 10 EB 18 E6 E6 00 60 5D A1 09 06 07 60 85 74 05 08 01 03 A6 0A 04 08 62 69 62 61 62 6F 62 61 8A 02 07 80 8B 07 60 85 74 05 08 02 02 AC 12 80 10 6F 2E 74 1D 0F 21 69 3B 6F 63 37 0F 25 6F 1D 0C BE 23 04 21 21 1F 10 00 00 00 00 01 00 00 00 06 5F 1F 04 00 62 1E 5D FF FF F3 B0 E6 E1 4C 6A B1 21 C9 0A 62 EA D2 1D 7E
14:34:13
7E A0 6B 61 02 23 30 2D 99 E6 E7 00 61 5C A1 09 06 07 60 85 74 05 08 01 03 A2 03 02 01 00 A3 05 A1 03 02 01 0E A4 0A 04 08 52 41 4F 32 34 30 36 30 AA 12 80 10 43 7B BE 90 16 89 9D 7E 77 C6 2F 26 98 88 F5 B4 BE 23 04 21 28 1F 10 00 00 00 00 08 00 06 5F 1F 04 00 00 1A 1D 03 E8 00 07 9F 7E 4D 11 8A 18 8E DA 93 3A B7 E8 F6 A7 7E
Authentication is applied.
Decrypt settings: Security: Authentication Invocation Counter: 0 SystemTitle: 52 41 4F 32 34 30 36 30 AuthenticationKey: 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 30 BlockCipherKey: 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31
Encrypted: 0800065F1F0400001A1D03E800079F7E4D118A188EDA933AB7E8
The thread 11416 has exited with code 0 (0x0).
Encrypt settings: Security: Authentication Invocation Counter: 0 SystemTitle: 52 41 4F 32 34 30 36 30 AuthenticationKey: 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 30 BlockCipherKey: 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31
Exception thrown: 'System.NullReferenceException' in Gurux.DLMS.dll
The thread 18720 has exited with code 0 (0x0).
The thread 8436 has exited with code 0 (0x0).
Exception thrown: 'Gurux.DLMS.GXDLMSException' in Gurux.DLMS.dll
14:34:34 Disconnect request
The thread 29176 has exited with code 0 (0x0).
The thread 30124 has exited with code 0 (0x0).
The thread 13376 has exited with code 0 (0x0).
The thread 25480 has exited with code 0 (0x0).
14:34:34
7E A0 08 61 02 23 73 CD 55 7E
Exception thrown: 'Gurux.DLMS.GXDLMSException' in GXDLMSDirector.exe
Exception thrown: 'Gurux.DLMS.GXDLMSException' in GXDLMSDirector.exe
The thread 21428 has exited with code 0 (0x0).
Exception thrown: 'Gurux.DLMS.GXDLMSException' in GXDLMSDirector.exe
Gurux.DLMS.GXDLMSException: Connection is permanently rejected. No reason is given.
Gurux.DLMS.Internal.GXAPDU.ParsePDU2(GXDLMSSettings settings, GXICipher cipher, GXByteBuffer buff, GXDLMSTranslatorStructure xml) [skipped] \repos\Gurux.DLMS.Net\Development\Internal\GXAPDU.cs:line 1539
Gurux.DLMS.Internal.GXAPDU.ParsePDU(GXDLMSSettings settings, GXICipher cipher, GXByteBuffer buff, GXDLMSTranslatorStructure xml) [skipped]\repos\Gurux.DLMS.Net\Development\Internal\GXAPDU.cs:line 1049
Gurux.DLMS.GXDLMSClient.ParseAAREResponse(GXByteBuffer reply) [skipped]\repos\Gurux.DLMS.Net\Development\GXDLMSClient.cs:line 1118
GXDLMSDirector.GXDLMSCommunicator.ParseAAREResponse(GXByteBuffer data) [skipped]\repos\GXDLMSDirector\Development\GXDLMSCommunicator.cs:line 215
GXDLMSDirector.GXDLMSCommunicator.InitializeConnection(Boolean force) [skipped]\repos\GXDLMSDirector\Development\GXDLMSCommunicator.cs:line 1482
GXDLMSDirector.GXDLMSDevice.InitializeConnection() [skipped]\repos\GXDLMSDirector\Development\GXDLMSDevice.cs:line 327
GXDLMSDirector.MainForm.Connect(Object sender, GXAsyncWork work, Object[] parameters) [skipped]\repos\GXDLMSDirector\Development\MainForm.cs:line 1789
and the last one from Director UI log window:
14:34:08 Send SNRM request.
TX: 7E A0 08 02 23 61 93 DB 22 7E
14:34:08
RX: 7E A0 08 61 02 23 73 CD 55 7E
14:34:13 Send AARQ request.
TX: 7E A0 6C 02 23 61 10 EB 18 E6 E6 00 60 5D A1 09 06 07 60 85 74 05 08 01 03 A6 0A 04 08 62 69 62 61 62 6F 62 61 8A 02 07 80 8B 07 60 85 74 05 08 02 02 AC 12 80 10 6F 2E 74 1D 0F 21 69 3B 6F 63 37 0F 25 6F 1D 0C BE 23 04 21 21 1F 10 00 00 00 00 01 00 00 00 06 5F 1F 04 00 62 1E 5D FF FF F3 B0 E6 E1 4C 6A B1 21 C9 0A 62 EA D2 1D 7E
14:34:13
RX: 7E A0 6B 61 02 23 30 2D 99 E6 E7 00 61 5C A1 09 06 07 60 85 74 05 08 01 03 A2 03 02 01 00 A3 05 A1 03 02 01 0E A4 0A 04 08 52 41 4F 32 34 30 36 30 AA 12 80 10 43 7B BE 90 16 89 9D 7E 77 C6 2F 26 98 88 F5 B4 BE 23 04 21 28 1F 10 00 00 00 00 08 00 06 5F 1F 04 00 00 1A 1D 03 E8 00 07 9F 7E 4D 11 8A 18 8E DA 93 3A B7 E8 F6 A7 7E
14:34:34
RX: 7E A0 08 61 02 23 73 CD 55 7E
Btw, there is a small difference in DecryptAesGcm code
C#:
if (p.Security == Security.Authentication)
{
length = len - 12 - 5;
python:
if security == Security.AUTHENTICATION:
len_ = len(data) - data.position - 12
Though in my case result lenght/len_ values are the same, so encryptedData size is the same. so jfyi,
Hi Andrew, This is fixed to…
Hi Andrew,
This is fixed to version 9.0.2502.0301.
BR,
Mikko