LWMESH Security - Page 1
Forum section: electronics / beginners

author: Peili
author_rank: Regular Contributor
timestamp: January 04, 2019, 07:15:25 am
content: hello, i want to implement a security to my LwMesh.. i'm using 1.2.1 version.. how to implement the security feature to the stack?

author: ataradov
author_rank: Super Contributor
timestamp: January 04, 2019, 07:28:45 am
content: If you want security that is included with the stack, then just enable NWK_ENABLE_SECURITY option in the configuration file. You also need to set security mode SYS_SECURITY_MODE.Then your application needs to set the same encryption key on all devices using NWK_SetSecurityKey() function.This is pretty well described in the documentation. What specific problems do you have?

author: Peili
author_rank: Regular Contributor
timestamp: January 07, 2019, 05:40:25 am
content: Quote from: ataradov on January 04, 2019, 07:28:45 amHow to check the Security feature is activated ? i'm enabled the NWK_ENABLE_SECURITY,SYS_SECURITY_MODE features and NWK_SetSecurityKey().. How to check the security?

author: ataradov
author_rank: Super Contributor
timestamp: January 07, 2019, 05:42:28 am
content: One way would be to look in the sniffer. You should not see plain text data.Anther indirect way is to set different keys on two nodes and check that they don't communicate.And remember to request encryption in your data requests.

author: Peili
author_rank: Regular Contributor
timestamp: January 07, 2019, 07:10:37 am
content: Quote from: ataradov on January 07, 2019, 05:42:28 ami have checked with and still they are communicating... what this mean?

author: ataradov
author_rank: Super Contributor
timestamp: January 07, 2019, 07:15:50 am
content: Do you set a security flag in the data request?

author: Peili
author_rank: Regular Contributor
timestamp: January 07, 2019, 09:02:43 am
content: Quote from: ataradov on January 07, 2019, 07:15:50 amdo you mean #define APP_SECURITY_KEY?

author: ataradov
author_rank: Super Contributor
timestamp: January 07, 2019, 09:05:14 am
content: No, I mean NWK_OPT_ENABLE_SECURITY in the "options" field of the NWK_DataReq_t structure you use to send the data.

author: Peili
author_rank: Regular Contributor
timestamp: January 07, 2019, 09:06:32 am
content: Quote from: ataradov on January 07, 2019, 09:05:14 amyes...appNwkDataReq.options = NWK_OPT_ACK_REQUEST | NWK_OPT_ENABLE_SECURITY;

author: ataradov
author_rank: Super Contributor
timestamp: January 07, 2019, 09:08:36 am
content: I would need to see the project to tell what may be wrong in that case.

author: Peili
author_rank: Regular Contributor
timestamp: January 07, 2019, 09:16:00 am
content: Quote from: ataradov on January 07, 2019, 09:08:36 ami'm attaching the configuration file and Wsndemo.c filesWSNDemo_C.c is the coordinator file and WSNDemo_R.c is for router

author: ataradov
author_rank: Super Contributor
timestamp: January 07, 2019, 09:20:14 am
content: Where and how do you configure APP_SECURITY_KEY?

author: Peili
author_rank: Regular Contributor
timestamp: January 07, 2019, 09:24:37 am
content: Quote from: ataradov on January 07, 2019, 09:20:14 amin the config.h file... i commented it to check whether it's working...

author: ataradov
author_rank: Super Contributor
timestamp: January 07, 2019, 09:26:19 am
content: So with this code, you set different keys on both sides and you get the data transferred correctly?

author: Peili
author_rank: Regular Contributor
timestamp: January 07, 2019, 09:27:38 am
content: Quote from: ataradov on January 07, 2019, 09:26:19 amyes.... first i set the#define APP_SECURITY_KEY "TestSecurityKey0" and then#define APP_SECURITY_KEY "Key0"but they are communicating

author: ataradov
author_rank: Super Contributor
timestamp: January 07, 2019, 09:31:01 am
content: The key must be 16 bytes long. Please read the documentation.Can you explain your test procedure step by step including all the changes, recompilations, device programmings, etc. Since I feel like you are doing something wrong.

author: Peili
author_rank: Regular Contributor
timestamp: January 09, 2019, 03:12:20 am
content: Quote from: ataradov on January 07, 2019, 09:31:01 amI have checked with the 16 byte key... now they are not communicating..if i enable #define NWK_ENABLE_SECURITY in Coordinator and doesn't in router, they will communicate.. but enabled in both they are not....

author: ataradov
author_rank: Super Contributor
timestamp: January 09, 2019, 03:16:50 am
content: If security is requested in the data request, but is not enabled in the stack configuration, then the flag in the request will be ignored and the data will be sent in plain text. And device that has security enabled can always receive plain text data in addition to the encrypted data, of course.In the NWK_DataInd_t structure there is a flag that tells whether data was received encrypted or not.But something else was wrong with your previous test anyway. It does not matter that the key was short, some leftover garbage was used as the remainder of the key. If the keys were different on both devices, they should not have been able to communicate.

author: Peili
author_rank: Regular Contributor
timestamp: January 09, 2019, 03:18:37 am
content: Quote from: ataradov on January 07, 2019, 09:31:01 amwe have one coordinator and one router.. i have some level sensors which send level to uart and we have to publish it.. i'm checking there is some special characters in the data , if true it's write to uart....

author: ataradov
author_rank: Super Contributor
timestamp: January 09, 2019, 03:20:28 am
content: That is not what I was asking for. I was asking for the testing steps, like this:1. Take the first board2. Set this the key to this value3. Compile application4. Program the device5. Take the second boardetc.

author: Peili
author_rank: Regular Contributor
timestamp: January 09, 2019, 03:27:45 am
content: Quote from: ataradov on January 09, 2019, 03:20:28 amfirst i took one board to configure as coordinator.. enabled #define NWK_ENABLE_SECURITY and set the key as TestSecurityKey0 and #define APP_ADDR as 0x0000..and compile the application and program it via atmel studio...then change the #define APP_ADDR as 0x1002 and compile the application ..then program the second board as a router via Atmel studio using AVR dragon....placed the second board in level sensor and coornator in my PC and open terminal to check the communication

author: ataradov
author_rank: Super Contributor
timestamp: January 09, 2019, 03:29:02 am
content: Ok, this is testing with the same key. So they should communicate.

author: Peili
author_rank: Regular Contributor
timestamp: January 09, 2019, 04:02:40 am
content: Quote from: ataradov on January 09, 2019, 03:29:02 amno they are not communicating...i tried with out enabling the #define NWK_ENABLE_SECURITY in the second board it's communicating

author: ataradov
author_rank: Super Contributor
timestamp: January 09, 2019, 04:16:40 am
content: First of all, please capitalize your sentences. I'm not going to put any effort into my posts, if you don't put any effort into yours.I'm also not going to be pulling formation from you. It is up to you to explain things as specifically as possible.Quote from: Peili on January 09, 2019, 04:02:40 amWhy was not this mentioned in the description of the situation?I'm completely lost in what you are doing. Start debugging. Put a debugger in a sending node and check that the outgoing frame is encrypted. Then out a debugger in the receiving node and check why incoming frame is getting rejected.

author: Peili
author_rank: Regular Contributor
timestamp: January 09, 2019, 07:02:11 am
content: Quote from: Peili on January 09, 2019, 04:02:40 amWhy was not this mentioned in the description of the situation?Quote from: Peili on January 09, 2019, 03:12:20 ami mentioned it

author: ataradov
author_rank: Super Contributor
timestamp: January 09, 2019, 07:04:06 am
content: All you mentioned was this:QuoteNo mention of the result of this test.Also, I will not respond to this thread anymore unless you properly capitalize sentences.

author: Peili
author_rank: Regular Contributor
timestamp: January 09, 2019, 10:22:26 am
content: Quote from: ataradov on January 09, 2019, 07:04:06 amSorry Alex...i forgot to mention it in that post...1. Take the first board2. Set the #define APP_SECURITY_KEY "TestSecurityKey0"and enabled #define NWK_ENABLE_SECURITY3. Compile application by setting address as 0x00004. Program the device using Atmel Studio via AVR Dragon5. Take the second board6.Set #define APP_SECURITY_KEY "TestSecurityKey0" && #define NWK_ENABLE_SECURITY7.Compile application by setting address as 0x10028.Program the device using Atmel Studio via AVR Dragon9. Connected the 1st board(Coordinator) to the Terminal and the 2nd board(router) to level sensor...10. They are not communicating... no value is writing to uart..11.Took the second board(router)12.Comment #define NWK_ENABLE_SECURITY13.Recompile the application and Program the board..14. connected it to Level Sensor and it send value to my coordinator..This is the result i have got through my testing.... Sorry for the things.. i have forgotten to mention it...

author: Peili
author_rank: Regular Contributor
timestamp: January 11, 2019, 10:21:42 am
content: Quote from: ataradov on January 09, 2019, 03:29:02 amhi, i have successfully completed the security with the same key... i had some errors in the file and that's why they were not communicating... Thank you Alex...Tested with different #define APP_SECURITY_KEY and tested the cases

author: Peili
author_rank: Regular Contributor
timestamp: February 28, 2019, 05:47:50 am
content: how can i add a code protection to the LwMesh 1_2_1 stack? is there any way to add it? please help

author: ataradov
author_rank: Super Contributor
timestamp: February 28, 2019, 05:48:58 am
content: What is code protection? And what it has to do wit the wireless stack?Also, capitalize your sentences, or I will not respond.