Update the LLS Secret of the Association Logical Name object issue

Project: 
gurux.dlms.c

In the server example 2, we are using a client with security low (default password : Gurux) to establish a connection with the server.

After reading the association logical name object, we tried to change the password.

Writing a password with length less than four characters works, anything else fails and throws an error.

By tracking the code, the error is "DLMS_ERROR_CODE_INCONSISTENT_OBJECT" found in:

- File "gxset.c" -> Function "cosem_getAssociationLogicalName" -> index = 7 -> Function "cosem_getOctectString(value->byteArr, &object->secret);" ->

-> File "cosem.c" -> Funtion "cosem_getOctectStringBase(gxByteBuffer* bb, gxByteBuffer* value, unsigned char type)" -> "if (count > bb_getCapacity(value))" -> return "DLMS_ERROR_CODE_INCONSISTENT_OBJECT"

In our case, we want the LLS secret length to be 8 characters.

Status: 
Closed (fixed)
Priority: 
Normal
Category: 
Bug report
Component: 
Code
Reporter: 
lara.wakim
Created: 
Fri, 06/12/2020 - 13:01
Updated: 
Mon, 06/15/2020 - 13:20

Comments

Administrator's picture

Status: Active » Closed (fixed)

After checking and testing the latest release number "20200612.1", we noticed that in the file "bytebuffer.c", you replaced the attribute of the function "bb_attach" from sizeof(V) to sizeof(V) / sizeof(V[0]). Due to this change, the function BB_ATTACH is throwing a warning "
dividing sizeof a pointer by another value".

You also added in the file "bytebuffer.c" in the function "bb_attach" this condition:
if (value == NULL || capacity < count)
{
return DLMS_ERROR_CODE_OUTOFMEMORY;
}
Due to this, each time we are using BB_ATTACH the code is entering this condition and affecting negatively all the code.
For example, in "BB_ATTACH(lowAssociation.secret, (unsigned char*) LLS_PASSWORD, (unsigned short)strlen(LLS_PASSWORD));", we were not able anymore to attach the password "Gurux" to the lowAssociation.secret that was consider as empty which brings the failure of the authentication. When, i commented the new added condition, the code worked like before.

Add to this that the main issue "Update the LLS Secret of the Association Logical Name object issue" is not resolved. On the contrary, when i try to update the password to a new one with a length more than 4 or even less, it always fails and throws this error : "Access error: device reports a inconsistent class or object". Worst, when we disconnect the server-client connection and we try to establish the connection again with the unchanged password, we are facing an authentication failure because the expected data of the password is still "Gurux" but the size of the expected password is saved equal to 0.

Hope, you can check these new issues and solve them.

Kurumi's picture

Hi,

Remove (unsigned char*). That is causing the problem. It should look like this:
BB_ATTACH(lowAssociation.secret, LLS_PASSWORD, (unsigned short)strlen(LLS_PASSWORD));

New BB_ATTACH_STR macro is added so warning is not shown with some compilers.
BB_ATTACH_STR(lowAssociation.secret, LLS_PASSWORD, (unsigned short)strlen(LLS_PASSWORD));

BR,
Mikko

Hi,

I did what you said, and it worked perfectly and the issue "Update the LLS Secret of the Association Logical Name object issue" is solved.

Thank you.

Best regards,

Lara Wakim