Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Announcements
  3. 💬 Security & Signing

💬 Security & Signing

Scheduled Pinned Locked Moved Announcements
137 Posts 20 Posters 17.5k Views 19 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • AnticimexA Anticimex

    @damian Hm, I don't find your debug prints you used earlier.
    But in general, I would say that the message object might be overwritten by the library, so if you need to use parts of it, make a copy of the parts you use first and then reference the copy to make sure a new incoming message does not overwrite it.
    Eg, in receive():

    void receive(const MyMessage &message) {
      if (message.type==V_STATUS) {                        
          bool value = message.getBool();
          uint8_t sensor = message.sensor;
          if (firstRun) {                                               
            relayState[sensor] = value;
            } else {                                                    
            controllerState[sensor] =  value;                       
            Serial.print("\nRelay State: ");
            Serial.println(relayState[sensor]);
            Serial.print("Switching to: ");
            Serial.println(controllerState[sensor]);
            if (controllerState[sensor] != relayState[sensor]) {                        
              relayState[sensor] = controllerState[sensor];                             
              wait(waitDelay);                                          
              send(msg[sensor].set(relayState[sensor]), false);                         
              }
            Serial.print("Relay state after if: ");
            Serial.println(relayState[sensor]);
            digitalWrite(RELAY_PIN+sensor, relayState[sensor] ? RELAY_ON : RELAY_OFF); 
            }
        }
    }
    

    And I believe the cause for your problem is that you do

    send(msg[message.sensor].set(relayState[message.sensor]), false);  
    

    after

    Serial.print("Switching to: ");
            Serial.println(controllerState[message.sensor]);
    

    but before

    Serial.print("Relay state after if: ");
            Serial.println(relayState[message.sensor]);
    

    so message might be changed between since the send() will request a nonce from the GW which then overwrites the buffer referenced by message.

    D Offline
    D Offline
    Damian
    wrote on last edited by Damian
    #121

    @anticimex Thank you, I'll test it and let you know if it helped. PS. debug prints sent before was created in cito, this is my original script. But you find it well, it was instead of:

    Serial.print("\nRelay State: ");
    Serial.println(relayState[sensor]);
    

    and

    Serial.print("Relay state after if: ");
    Serial.println(relayState[message.sensor]);
    

    So basically the sections that you've mentioned as a possibly buggy.

    1 Reply Last reply
    0
    • AnticimexA Anticimex

      @damian Hm, I don't find your debug prints you used earlier.
      But in general, I would say that the message object might be overwritten by the library, so if you need to use parts of it, make a copy of the parts you use first and then reference the copy to make sure a new incoming message does not overwrite it.
      Eg, in receive():

      void receive(const MyMessage &message) {
        if (message.type==V_STATUS) {                        
            bool value = message.getBool();
            uint8_t sensor = message.sensor;
            if (firstRun) {                                               
              relayState[sensor] = value;
              } else {                                                    
              controllerState[sensor] =  value;                       
              Serial.print("\nRelay State: ");
              Serial.println(relayState[sensor]);
              Serial.print("Switching to: ");
              Serial.println(controllerState[sensor]);
              if (controllerState[sensor] != relayState[sensor]) {                        
                relayState[sensor] = controllerState[sensor];                             
                wait(waitDelay);                                          
                send(msg[sensor].set(relayState[sensor]), false);                         
                }
              Serial.print("Relay state after if: ");
              Serial.println(relayState[sensor]);
              digitalWrite(RELAY_PIN+sensor, relayState[sensor] ? RELAY_ON : RELAY_OFF); 
              }
          }
      }
      

      And I believe the cause for your problem is that you do

      send(msg[message.sensor].set(relayState[message.sensor]), false);  
      

      after

      Serial.print("Switching to: ");
              Serial.println(controllerState[message.sensor]);
      

      but before

      Serial.print("Relay state after if: ");
              Serial.println(relayState[message.sensor]);
      

      so message might be changed between since the send() will request a nonce from the GW which then overwrites the buffer referenced by message.

      D Offline
      D Offline
      Damian
      wrote on last edited by Damian
      #122

      @anticimex Yep, remodelling receive() function by adding variables and assigning values respectively message.sensor and message.getBool at the beginning got the job done. Now it works like a charm. Moreover, the whitelisting feature also works now - I had to do something wrong previously. Thank you once again for your help.

      AnticimexA 1 Reply Last reply
      0
      • D Damian

        @anticimex Yep, remodelling receive() function by adding variables and assigning values respectively message.sensor and message.getBool at the beginning got the job done. Now it works like a charm. Moreover, the whitelisting feature also works now - I had to do something wrong previously. Thank you once again for your help.

        AnticimexA Offline
        AnticimexA Offline
        Anticimex
        Contest Winner
        wrote on last edited by
        #123

        @damian great to hear! Happy secure home automating :)

        Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

        1 Reply Last reply
        0
        • alowhumA Offline
          alowhumA Offline
          alowhum
          Plugin Developer
          wrote on last edited by
          #124

          This page is not up to date, and this is causing some confusion:
          https://github.com/tsathishkumar/MySController-rs/issues/15

          AnticimexA 1 Reply Last reply
          0
          • alowhumA alowhum

            This page is not up to date, and this is causing some confusion:
            https://github.com/tsathishkumar/MySController-rs/issues/15

            AnticimexA Offline
            AnticimexA Offline
            Anticimex
            Contest Winner
            wrote on last edited by
            #125

            @alowhum but that is not part of the core library, right? So this thread is perhaps not the best place for discussing 3rd party tools.

            Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

            1 Reply Last reply
            0
            • alowhumA Offline
              alowhumA Offline
              alowhum
              Plugin Developer
              wrote on last edited by alowhum
              #126

              "This thread contains comments for the article "Security & Signing" posted on MySensors.org."

              @Anticimex This thread is the thread attached to a page on MySensors.org about security.

              I pointed to that (awesome) tool on Github as an example that the page has caused some confusion about whether or not MySensors supports encryption.

              AnticimexA 3 Replies Last reply
              0
              • alowhumA alowhum

                "This thread contains comments for the article "Security & Signing" posted on MySensors.org."

                @Anticimex This thread is the thread attached to a page on MySensors.org about security.

                I pointed to that (awesome) tool on Github as an example that the page has caused some confusion about whether or not MySensors supports encryption.

                AnticimexA Offline
                AnticimexA Offline
                Anticimex
                Contest Winner
                wrote on last edited by
                #127

                @alowhum ok, thanks. Well we do. So please notify that author.

                Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

                1 Reply Last reply
                0
                • alowhumA alowhum

                  "This thread contains comments for the article "Security & Signing" posted on MySensors.org."

                  @Anticimex This thread is the thread attached to a page on MySensors.org about security.

                  I pointed to that (awesome) tool on Github as an example that the page has caused some confusion about whether or not MySensors supports encryption.

                  AnticimexA Offline
                  AnticimexA Offline
                  Anticimex
                  Contest Winner
                  wrote on last edited by
                  #128

                  @alowhum as for the link back to mysensors documentation, that documentation is about message signing which is not to be confused with encryption. And on the top of the article is links to the latest documentation which should reflect the latest status on both signing and encryption.

                  Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

                  1 Reply Last reply
                  0
                  • alowhumA alowhum

                    "This thread contains comments for the article "Security & Signing" posted on MySensors.org."

                    @Anticimex This thread is the thread attached to a page on MySensors.org about security.

                    I pointed to that (awesome) tool on Github as an example that the page has caused some confusion about whether or not MySensors supports encryption.

                    AnticimexA Offline
                    AnticimexA Offline
                    Anticimex
                    Contest Winner
                    wrote on last edited by
                    #129

                    @alowhum @hek we should perhaps retire that article or reduce it to a reference to the "actual" documentation instead to reduce the risk of confusion?

                    Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

                    1 Reply Last reply
                    0
                    • hekH Offline
                      hekH Offline
                      hek
                      Admin
                      wrote on last edited by hek
                      #130

                      Yes, maybe we could add a more prominent link in the article to the auto generated documentation. Right now the link easily missed in the ingress.... and it does not link directly to the overview documentation here:
                      https://www.mysensors.org/apidocs/group__MySigninggrpPub.html

                      I don't think we should scrap the page entirely as it contains the none API technical parts as a good overview.

                      1 Reply Last reply
                      1
                      • alowhumA Offline
                        alowhumA Offline
                        alowhum
                        Plugin Developer
                        wrote on last edited by
                        #131

                        @hek said in 💬 Security & Signing:

                        https://www.mysensors.org/apidocs/group__MySigninggrpPub.html

                        That link still only refers to details about signing, and not encryption. So a user wanting to learn about security might still come away with the idea that only signing is supported.

                        AnticimexA 1 Reply Last reply
                        0
                        • alowhumA alowhum

                          @hek said in 💬 Security & Signing:

                          https://www.mysensors.org/apidocs/group__MySigninggrpPub.html

                          That link still only refers to details about signing, and not encryption. So a user wanting to learn about security might still come away with the idea that only signing is supported.

                          AnticimexA Offline
                          AnticimexA Offline
                          Anticimex
                          Contest Winner
                          wrote on last edited by
                          #132

                          @alowhum yes, it should link here: https://www.mysensors.org/apidocs/group__SecuritySettingGrpPub.html

                          Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

                          alowhumA 1 Reply Last reply
                          1
                          • AnticimexA Anticimex

                            @alowhum yes, it should link here: https://www.mysensors.org/apidocs/group__SecuritySettingGrpPub.html

                            alowhumA Offline
                            alowhumA Offline
                            alowhum
                            Plugin Developer
                            wrote on last edited by
                            #133

                            @anticimex Great!

                            1 Reply Last reply
                            0
                            • YoshuY Offline
                              YoshuY Offline
                              Yoshu
                              wrote on last edited by
                              #134

                              Hi All not sure if this should be under gateway or security sections but just wondering If it is possible to run 2 seperate gateways for mysensors netwok

                              • a fully secured network with signing required both node and gateway for all nodes required to send and or receive signed data.
                                -A second unsecured network for gerneral sensor data and equipment not requiring any security
                              AnticimexA 1 Reply Last reply
                              0
                              • YoshuY Yoshu

                                Hi All not sure if this should be under gateway or security sections but just wondering If it is possible to run 2 seperate gateways for mysensors netwok

                                • a fully secured network with signing required both node and gateway for all nodes required to send and or receive signed data.
                                  -A second unsecured network for gerneral sensor data and equipment not requiring any security
                                AnticimexA Offline
                                AnticimexA Offline
                                Anticimex
                                Contest Winner
                                wrote on last edited by
                                #135

                                @Yoshu it is possible. When you have two gateways, the networks will be completely isolated so you can run one of them secured while the other is not.
                                You might need to distinguish the nodes on in your controller by giving them static unique ID:s unless your controller ties the identifiers to each gateway or it might be difficult to determine which mysensors network a node belong to.

                                Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

                                L 1 Reply Last reply
                                0
                                • AnticimexA Anticimex

                                  @Yoshu it is possible. When you have two gateways, the networks will be completely isolated so you can run one of them secured while the other is not.
                                  You might need to distinguish the nodes on in your controller by giving them static unique ID:s unless your controller ties the identifiers to each gateway or it might be difficult to determine which mysensors network a node belong to.

                                  L Offline
                                  L Offline
                                  lood29
                                  wrote on last edited by
                                  #136

                                  @Anticimex more important is to set different network id or you'll have lot of collisions and lost packets

                                  AnticimexA 1 Reply Last reply
                                  0
                                  • L lood29

                                    @Anticimex more important is to set different network id or you'll have lot of collisions and lost packets

                                    AnticimexA Offline
                                    AnticimexA Offline
                                    Anticimex
                                    Contest Winner
                                    wrote on last edited by
                                    #137

                                    @lood29 That is correct, assuming the same radio technology is used. Typically, you set up a separate gateway because you want to run a sensor network on a different radio family due to longer distances or similar.

                                    Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

                                    1 Reply Last reply
                                    1
                                    Reply
                                    • Reply as topic
                                    Log in to reply
                                    • Oldest to Newest
                                    • Newest to Oldest
                                    • Most Votes


                                    20

                                    Online

                                    11.7k

                                    Users

                                    11.2k

                                    Topics

                                    113.1k

                                    Posts


                                    Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                    • Login

                                    • Don't have an account? Register

                                    • Login or register to search.
                                    • First post
                                      Last post
                                    0
                                    • MySensors
                                    • OpenHardware.io
                                    • Categories
                                    • Recent
                                    • Tags
                                    • Popular