Skip to main content
Home
for DLMS smart meters

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Forums
  3. Data Encryption Problem

Data encryption problem

Forum Rules

Before commenting read Forum rules

Don't comment the topic if you have a new question.

You can create a new topic selecting correct category from Gurux Forum and then create a new topic selecting "New Topic" from the top left.

By Rostislav, 20 June, 2022
Forums
Known problems

Hi, Mikko!

I have a very strange problem: if I turn on encryption, then when reading the data with only one packet, there are no errors. Successful authentication indicates this. But if I split the packet into two segments, then the data is not decrypted in GXDLMSDirector. To make sure I'm not violating the structural integrity of the data when passing it to the GXDLMSDirector, I specifically turned off encryption temporarily for this purpose and passed the data unencrypted. Thus, in the log with unencrypted data, it is clear that their length and content do not have structural errors.

What could be wrong in your opinion?

Thanks in advance for your help!

BR,
Rostislav

--- Log

21:35:41 Initializing serial connection.
21:35:42 Send SNRM request.
7E A0 08 02 23 61 93 DB 22 7E
21:35:42
7E A0 08 61 02 23 73 CD 55 7E
21:35:42 Parsing UA reply succeeded.
21:35:42 Send AARQ request.
7E A0 60 02 23 61 10 DB 6F E6 E6 00 60 51 A1 09 06 07 60 85 74 05 08 01 03 A6 0A 04 08 41 42 43 44 45 46 47 48 8A 02 07 80 8B 07 60 85 74 05 08 02 02 AC 12 80 10 01 55 4D 3F 55 16 00 12 0C 67 5A 78 39 28 79 12 BE 17 04 15 21 13 20 00 00 00 00 1F 58 4B 30 32 AF 28 57 07 70 D8 8D 83 70 38 E6 7E
21:35:42
7E A0 6C 61 02 23 30 F1 A9 E6 E7 00 61 5D 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 41 42 43 44 45 46 47 48 88 02 07 80 89 07 60 85 74 05 08 02 02 AA 12 80 10 4D D3 4D D3 D0 7F D0 7F 4C 40 4C 40 7E BC 7E BC BE 17 04 15 28 13 20 00 00 00 00 16 58 4D 6F 2B F4 37 53 19 6D D8 D0 81 77 38 09 7E
21:35:42 Parsing AARE reply succeeded.
21:35:42 Authenticating.
7E A0 33 02 23 61 32 65 05 E6 E6 00 CB 24 20 00 00 00 01 37 5E 30 E4 B5 90 1D C3 80 9F EE 74 9D 6D 90 82 F5 E7 6C 50 C8 D9 24 82 A1 53 FA 84 98 CB F8 4C E2 7E
21:35:43
7E A0 2C 61 02 23 52 C7 28 E6 E7 00 CF 1D 20 00 00 00 01 33 5E 30 E4 BB 90 14 FB 68 21 83 EE A2 A5 3D 80 CA 87 2D 0E 9E 0B E4 81 EE 3D 7E
21:35:44 Read object type ScriptTable index: 2
7E A0 21 02 23 61 54 9D A1 E6 E6 00 C8 12 20 00 00 00 02 E2 7E 21 A9 F5 6D 32 D2 9B 29 40 BC F4 52 3D 7E
21:35:44
7E A8 6E 61 02 23 74 01 9A E6 E7 00 CC 82 00 7B 20 00 00 00 02 E6 7E 21 A9 FD 69 30 DA 89 4D BE BF F5 0B B6 6A DB A9 DD A5 20 13 D5 5F 7C 66 A0 4E 66 35 C8 07 CF AC 4C 6A 64 82 96 B5 6F A8 41 AD CA E7 61 DE 1D 8F 87 30 D7 18 33 F0 DE 69 D6 1A 4F 90 88 FA DA 55 01 F6 B1 DA 67 75 3C F1 77 53 33 95 DB 32 79 96 C8 AC 55 8E 07 49 BA E2 7E
21:35:44 Get next frame.
21:35:44 Read object type ScriptTable index: 2
7E A0 08 02 23 61 71 C7 E6 7E
21:35:44
7E A0 28 61 02 23 76 F1 62 76 4C E2 AB EE 6D 36 D9 9A 4F BA A8 F5 1B B3 7A D3 BD DD A3 27 15 D4 A0 7D 62 AB B3 3D 05 75 89 7E
System.Exception: Invalid data type.
в Gurux.DLMS.Internal.GXCommon.GetData(GXDLMSSettings settings, GXByteBuffer data, GXDataInfo info)
в Gurux.DLMS.Internal.GXCommon.GetArray(GXDLMSSettings settings, GXByteBuffer buff, GXDataInfo info, Int32 index)
в Gurux.DLMS.Internal.GXCommon.GetData(GXDLMSSettings settings, GXByteBuffer data, GXDataInfo info)
в Gurux.DLMS.GXDLMS.GetValueFromData(GXDLMSSettings settings, GXReplyData reply)
в Gurux.DLMS.GXDLMS.GetPdu(GXDLMSSettings settings, GXReplyData data)
в Gurux.DLMS.GXDLMS.HandleGloDedResponse(GXDLMSSettings settings, GXReplyData data, Int32 index)
в Gurux.DLMS.GXDLMS.GetPdu(GXDLMSSettings settings, GXReplyData data)
в Gurux.DLMS.GXDLMS.GetPdu(GXDLMSSettings settings, GXReplyData data)
в Gurux.DLMS.GXDLMS.GetData(GXDLMSSettings settings, GXByteBuffer reply, GXReplyData data, GXReplyData notify)
в Gurux.DLMS.GXDLMSClient.GetData(GXByteBuffer reply, GXReplyData data, GXReplyData notify)
в GXDLMSDirector.GXDLMSCommunicator.ReadDLMSPacket(Byte[] data, Int32 tryCount, GXReplyData reply)
в GXDLMSDirector.GXDLMSCommunicator.ReadDLMSPacket(Byte[] data, GXReplyData reply)
в GXDLMSDirector.GXDLMSCommunicator.ReadDataBlock(Byte[] data, String text, Int32 multiplier, Int32 tryCount, GXReplyData reply)
в GXDLMSDirector.GXDLMSCommunicator.ReadDataBlock(Byte[] data, String text, Int32 multiplier, GXReplyData reply)
в GXDLMSDirector.GXDLMSCommunicator.ReadDataBlock(Byte[] data, String text, GXReplyData reply)
в GXDLMSDirector.GXDLMSCommunicator.ReadDataBlock(Byte[][] data, String text, GXReplyData reply)
в GXDLMSDirector.GXDLMSCommunicator.Read(Object sender, GXDLMSObject obj, Boolean forceRead)
в GXDLMSDirector.MainForm.Read(Object sender, GXAsyncWork work, Object[] parameters)

--- Encryption OFF for check data cipher and data length

21:23:33 Read object type ScriptTable index: 2
TX: 7E A0 21 02 23 61 54 9D A1 E6 E6 00 C8 12 20 00 00 00 02 E2 7E 21 A9 F5 6D 32 D2 9B 29 40 BC F4 52 3D 7E
21:23:33
RX: 7E A8 6E 61 02 23 74 01 9A E6 E7 00 CC 82 00 7B 20 00 00 00 02 C4 01 C1 00 01 04 02 02 12 00 01 01 01 02 05 16 01 12 00 06 09 06 00 00 0E 00 01 FF 0F 04 0A 02 54 31 02 02 12 00 02 01 01 02 05 16 01 12 00 06 09 06 00 00 0E 00 01 FF 0F 04 0A 02 54 32 02 02 12 00 03 01 01 02 05 16 01 12 00 06 09 06 00 00 0E 00 01 FF 0F 04 0A 02 99 C7 7E
21:23:33
TX: 7E A0 08 02 23 61 71 C7 E6 7E
21:23:33
RX: 7E A0 28 61 02 23 76 F1 62 54 33 02 02 12 00 04 01 01 02 05 16 01 12 00 06 09 06 00 00 0E 00 01 FF 0F 04 0A 02 54 34 74 43 7E

--- Parsing cipher data

E6 E7 00 CC 82 00 7B 20 00 00 00 02
C4 01 C1 00
01 04
02 02
12 00 01
01 01
02 05
16 01
12 00 06
09 06 00 00 0E 00 01 FF
0F 04
0A 02 54 31
02 02
12 00 02
01 01
02 05
16 01
12 00 06
09 06 00 00 0E 00 01 FF
0F 04
0A 02 54 32
02 02
12 00 03
01 01
02 05
16 01
12 00 06
09 06 00 00 0E 00 01 FF
0F 04
0A 02 54 33
02 02
12 00 04
01 01
02 05
16 01
12 00 06
09 06 00 00 0E 00 01 FF
0F 04
0A 02 54 34

Image

Rostislav

3 years 5 months ago

Encryption setup

Encryption setup

Image
Profile picture for user Kurumi

Kurumi

3 years 5 months ago

Hi,

Hi,

There are extra bytes and the last string is corrupted.

0F 04
0A 02 //Missing 54 34
//Extra bytes
28 AE
D8 3F B4 BC 43 8C 99 F6 43 53 39 22 1C 8D 78 BB 34 CD FE 31 9D 14 6E A8 EC 11 27 57}

Make sure that you don't encrypt the data twice.

BR,
Mikko

Rostislav

3 years 5 months ago

Hi, Mikko!

Hi, Mikko!
Many thanks for the help!
The data is encrypted only once, I checked that.
I moved bytes 54 34 to the end of the first packet. However, the error remains, but it is different. Please see:

--- Partially unencrypted exchange for data integrity control
11:57:22 Read object type ScriptTable index: 2
7E A0 21 02 23 61 54 9D A1 E6 E6 00 C8 12 20 00 00 00 02 E2 7E 21 A9 F5 6D 32 D2 9B 29 40 BC F4 52 3D 7E
11:57:22
7E A8 70 61 02 23 74 F9 4F E6 E7 00 CC 82 00 7B 20 00 00 00 02 C4 01 C1 00 01 04 02 02 12 00 01 01 01 02 05 16 01 12 00 06 09 06 00 00 0E 00 01 FF 0F 04 0A 02 54 31 02 02 12 00 02 01 01 02 05 16 01 12 00 06 09 06 00 00 0E 00 01 FF 0F 04 0A 02 54 32 02 02 12 00 03 01 01 02 05 16 01 12 00 06 09 06 00 00 0E 00 01 FF 0F 04 0A 02 54 33 3E C4 7E
11:57:22 Get next frame.
11:57:22 Read object type ScriptTable index: 2
7E A0 08 02 23 61 71 C7 E6 7E
11:57:22
7E A0 26 61 02 23 76 49 03 02 02 12 00 04 01 01 02 05 16 01 12 00 06 09 06 00 00 0E 00 01 FF 0F 04 0A 02 54 34 5B 04 7E

--- Encrypted exchange
12:05:38 Read object type ScriptTable index: 2
7E A0 21 02 23 61 54 9D A1 E6 E6 00 C8 12 20 00 00 00 02 E2 7E 21 A9 F5 6D 32 D2 9B 29 40 BC F4 52 3D 7E
12:05:38
7E A8 70 61 02 23 74 F9 4F E6 E7 00 CC 82 00 7B 20 00 00 00 02 E6 7E 21 A9 FD 69 30 DA 89 4D BE BF F5 0B B6 6A DB A9 DD A5 20 13 D5 5F 7C 66 A0 4E 66 35 C8 07 CF AC 4C 6A 64 82 96 B5 6F A8 41 AD CA E7 61 DE 1D 8F 87 30 D7 18 33 F0 DE 69 D6 1A 4F 90 88 FA DA 55 01 F6 B1 DA 67 75 3C F1 77 53 33 95 DB 32 79 96 C8 AC 55 8E 07 49 0A D1 31 36 7E
12:05:38 Get next frame.
12:05:38 Read object type ScriptTable index: 2
7E A0 08 02 23 61 71 C7 E6 7E
12:05:38
7E A0 26 61 02 23 76 49 03 20 7D F2 A9 F8 6C 33 DA 9E 5B BE AC F4 0F BA 7A DA BB D3 A3 28 EA DA 5B 78 64 F5 85 BC 4F 7E
System.InvalidCastException: Failed to cast object type "Gurux.DLMS.GXDate" at type "System.Object[]".
в Gurux.DLMS.Objects.GXDLMSScriptTable.Gurux.DLMS.Objects.IGXDLMSBase.SetValue(GXDLMSSettings settings, ValueEventArgs e)
в Gurux.DLMS.GXDLMSClient.UpdateValue(GXDLMSObject target, Int32 attributeIndex, Object value, List`1 columns)
в Gurux.DLMS.GXDLMSClient.UpdateValue(GXDLMSObject target, Int32 attributeIndex, Object value)
в GXDLMSDirector.GXDLMSCommunicator.Read(Object sender, GXDLMSObject obj, Boolean forceRead)
в GXDLMSDirector.MainForm.Read(Object sender, GXAsyncWork work, Object[] parameters)

Profile picture for user Kurumi

Kurumi

3 years 5 months ago

Hi,

Hi,

Don't move 54 34 to the end of the first frame. Check why 54 34 are missing from the end of the second frame and why there are extra bytes. Now the content is invalid after the decryption.

BR,
Mikko

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Tue, 12/02/2025 - 10:21
    gurux.dlms.c 9.0.2512.0201
  • Mon, 12/01/2025 - 13:55
    Gurux.DLMS.Python 1.0.193
  • Thu, 11/13/2025 - 15:23
    Gurux.DLMS.Python 1.0.192
  • Thu, 11/13/2025 - 14:55
    gurux.dlms.java 4.0.84
  • Wed, 10/29/2025 - 08:51
    gurux.dlms.c 9.0.2510.2901

New forum topics

  • Incomplete Firmware Upgrade Process
  • SNRM byte mening
  • P384 Client Certificate incorrect issuer CN
  • Confirmed push service support
  • DLMS Stack hang during Firmware Upgrade
More

Who's new

  • radu
  • diroccon
  • amelara
  • stasxol
  • Shaheer Tariq
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin