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. Development
  3. [security] Migrating from library version 2.1 to 2.2

[security] Migrating from library version 2.1 to 2.2

Scheduled Pinned Locked Moved Development
48 Posts 7 Posters 9.2k Views 9 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 Offline
    AnticimexA Offline
    Anticimex
    Contest Winner
    wrote on last edited by Anticimex
    #1

    Once library version 2.2 is released (it is currently in beta and available on the development branch on GitHub) users that were using signing or encryption will have to re-do personalization. This is because in 2.2, a checksum has been added to the security data in EEPROM to avoid usage of tampered or accidentally wiped data.
    Migrating the data is not complicated as personalization in 2.2 has been rewritten to be simpler to use.

    There are a few options here. The simplest is to just re-do personalization from scratch. The new SecurityPersonalizer will guide you through the process. Just execute it unmodified on the device and follow the instructions in the serial console.

    If you want to reuse an existing AES or HMAC key , follow this procedure:

    1. Execute the SecurityPersonalizer example without any modification on your device. Then take note of the EEPROM contents displayed. It can look something like this:
    +------------------------------------------------------------------------------------+
    |                                       EEPROM                                       |
    +--------+--------+------------------------------------------------------------------+
    | Key ID | Status | Key                                                              |
    +--------+--------+------------------------------------------------------------------+
    | HMAC   | RESET  | FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF |
    | AES    | RESET  | FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF                                 |
    | SERIAL | RESET  | FFFFFFFFFFFFFFFFFF                                               |
    +--------+--------+------------------------------------------------------------------+
    
    1. Copy the HMAC and/or SERIAL and/or AES key (if you use soft signing) or only the AES key (if you use ATSHA204 based signing) and put the values into the following lines in the SecurityPersonalizer.ino file (leave the default values of the HMAC and SERIAL for ATSHA204 based signing):
    #define MY_HMAC_KEY 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
    
    #define MY_AES_KEY 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
    
    #define MY_SOFT_SERIAL 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
    
    1. Uncomment this line:
    //#define PERSONALIZE_SOFT
    
    1. Execute the sketch again. Now the data will be rewritten to EEPROM and a checksum will be calculated and stored. For hardware based signing, the "old" HMAC key will remain in use, but the checksum will be updated for the AES key (it will also cover the software HMAC and SERIAL, but they are not used for hardware based signing).

    If you do not use, nor plan to use, whitelisting, you can leave the SERIAL value as is, and execute the modified personalizer without further modifications on every devie. If you plan to use (or already use) whitelisting, you need to rewrite the proper serial on all devices as well (users of hardware based signing can ignore this, as the serial of the ATSHA204A is used and is fixed to each device.
    Note that if you change the SERIAL compared to what was stored previously, you also will need to update all whitelists that has an entry for that node.

    EDIT: Obviously, do NOT copy your ATSHA204A HMAC key and store it in EEPROM. It would negate the benefit of the ATSHA readback protection.

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

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

      I'm looking forward to it become stable! I've been playing with the MY_SIGNING_SIMPLE_PASSWD option and I love it! No more neighbours picking up my data!

      AnticimexA 1 Reply Last reply
      0
      • alowhumA alowhum

        I'm looking forward to it become stable! I've been playing with the MY_SIGNING_SIMPLE_PASSWD option and I love it! No more neighbours picking up my data!

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

        @alowhum Nice to hear. It is stable now.

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

        alowhumA 1 Reply Last reply
        1
        • AnticimexA Anticimex

          @alowhum Nice to hear. It is stable now.

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

          @anticimex I just noticed. Brilliant.

          One thing that I must admit is that I am a little sad that the option I was advocating for about a year ago hasn't really become the option I was hoping for. I suspect that's because I didn't now enough about the difference between signing and encryption, so I was unable to argue well enough what I was looking for.

          Perhaps it can still be a feature request for 2.3: the ability to just put a password at the top of the scripts, and then automatically have encrypted communication on the network. Without signing. As this allows me (and other relative n00bs) to keep using my low-memory Nano's. Because when I tried to implement the current easy option I ran out of memory on almost all the nodes. Which prompted my question about the future of MySensors, and the implied need to upgrade to ARM based devices.

          Again, I know what I am looking for is very poor security. But all I want is to have a really easy pathway (high usability) that lowers the incentive for my neighbour to snoop my network. To go from "hey, look, a node has popped up in Domoticz. Let's see how much power my neighbour uses" to "no node has popped up in Domoticz".

          As I read in the Raspberry gateway thread, creating a simple, encrypted network has in a way become harder. Now all nodes need their own unique key. Hence the sadness, as it seems that upgrading my Nano network to an encrypted state without having to dive into technical details, code generation, signing process and allround effort is actually further away than it was before.

          At least, that's what it seems like. I would be happy to be wrong :-)

          AnticimexA 1 Reply Last reply
          0
          • gohanG Offline
            gohanG Offline
            gohan
            Mod
            wrote on last edited by
            #5

            I'm waiting too to figure out how to get encryption on the rpi gateway

            AnticimexA 2 Replies Last reply
            0
            • gohanG gohan

              I'm waiting too to figure out how to get encryption on the rpi gateway

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

              @gohan have you tried to run mysgw --help?

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

              1 Reply Last reply
              0
              • gohanG gohan

                I'm waiting too to figure out how to get encryption on the rpi gateway

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

                @gohan feature toggles for the rPi gateways are documented: https://www.mysensors.org/apidocs/group__RaspberryPiGateway.html

                Regarding the configuration of these features, I don't think there is anything in doxygen for that yet, but you should get a list with mysgw -h or --help

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

                1 Reply Last reply
                0
                • alowhumA alowhum

                  @anticimex I just noticed. Brilliant.

                  One thing that I must admit is that I am a little sad that the option I was advocating for about a year ago hasn't really become the option I was hoping for. I suspect that's because I didn't now enough about the difference between signing and encryption, so I was unable to argue well enough what I was looking for.

                  Perhaps it can still be a feature request for 2.3: the ability to just put a password at the top of the scripts, and then automatically have encrypted communication on the network. Without signing. As this allows me (and other relative n00bs) to keep using my low-memory Nano's. Because when I tried to implement the current easy option I ran out of memory on almost all the nodes. Which prompted my question about the future of MySensors, and the implied need to upgrade to ARM based devices.

                  Again, I know what I am looking for is very poor security. But all I want is to have a really easy pathway (high usability) that lowers the incentive for my neighbour to snoop my network. To go from "hey, look, a node has popped up in Domoticz. Let's see how much power my neighbour uses" to "no node has popped up in Domoticz".

                  As I read in the Raspberry gateway thread, creating a simple, encrypted network has in a way become harder. Now all nodes need their own unique key. Hence the sadness, as it seems that upgrading my Nano network to an encrypted state without having to dive into technical details, code generation, signing process and allround effort is actually further away than it was before.

                  At least, that's what it seems like. I would be happy to be wrong :-)

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

                  @alowhum I don't understand what you mean? You have MY_SIGNING_SIMPLE_PASSWD. It enables signing and encryption with out any further configurations. Why would you not want to enable signing? And the password option is also available on the raspberry pi port as documented here: https://www.mysensors.org/apidocs/group__RaspberryPiGateway.html
                  The documentation is unclear on the implications of the password flag, but it does enable encryption as well: --my-signing-password=<PASSWORD>

                  The general documentation on security details the use of the password flag: https://www.mysensors.org/apidocs/group__SigningSettingGrpPub.html#gaedf8ec407fbde609a520ea0d95da2aac

                  I am afraid things can't get much simpler than this.
                  If you disagree please elaborate on what you think can be simplified.

                  If you for some reason still want (very crappy) encryption only, just change in MyConfig.h to disable the signing flags to not enable them. I don't want to clutter the code with more switches for security. It helps no-one.
                  https://github.com/mysensors/MySensors/blob/development/MyConfig.h#L1523

                  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
                    #9

                    Hey @Anticimex, thanks for the reply.

                    The simple version is really great, don't get me wrong. Absolutely great usability!

                    The reason I would like a non-signing option is that it saves a lot of ram. By only using encryption it should be possible to continue using Arduino Nano's as nodes.

                    I tried using the MY_SIGNING_SIMPLE_PASSWD option on my Nano's, and the result was that most of my sketches became too big or unstable.

                    There just isn't enough space/ram for both hardcore security and sensor libraries.

                    Thanks for explaining that I might be able to 'criple' the MY_SIGNING_SIMPLE_PASSWD option. I would suggest that this 'crippling' could perhaps become a feature in itself called "MY_ENCRYPTION_SIMPLE_PASSWD (without the signing).

                    AnticimexA S 2 Replies Last reply
                    0
                    • alowhumA alowhum

                      Hey @Anticimex, thanks for the reply.

                      The simple version is really great, don't get me wrong. Absolutely great usability!

                      The reason I would like a non-signing option is that it saves a lot of ram. By only using encryption it should be possible to continue using Arduino Nano's as nodes.

                      I tried using the MY_SIGNING_SIMPLE_PASSWD option on my Nano's, and the result was that most of my sketches became too big or unstable.

                      There just isn't enough space/ram for both hardcore security and sensor libraries.

                      Thanks for explaining that I might be able to 'criple' the MY_SIGNING_SIMPLE_PASSWD option. I would suggest that this 'crippling' could perhaps become a feature in itself called "MY_ENCRYPTION_SIMPLE_PASSWD (without the signing).

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

                      @alowhum I will consider it for 2.2.1. But I also need to mind the complexity of the overall functionality. I don't want the security solution to grow more into a beast than it already is.
                      The functionality you seek is really simple to implement. But gives even more options for a user to decide on. And although that is for some a great thing it is not for everyone.
                      I will see if I can somehow structure the documentation to outline all the configuration settings and try to give each a elaborate description on pros and cons.

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

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

                        I can't ask for much more than that. Thanks man!

                        AnticimexA 1 Reply Last reply
                        0
                        • alowhumA alowhum

                          Hey @Anticimex, thanks for the reply.

                          The simple version is really great, don't get me wrong. Absolutely great usability!

                          The reason I would like a non-signing option is that it saves a lot of ram. By only using encryption it should be possible to continue using Arduino Nano's as nodes.

                          I tried using the MY_SIGNING_SIMPLE_PASSWD option on my Nano's, and the result was that most of my sketches became too big or unstable.

                          There just isn't enough space/ram for both hardcore security and sensor libraries.

                          Thanks for explaining that I might be able to 'criple' the MY_SIGNING_SIMPLE_PASSWD option. I would suggest that this 'crippling' could perhaps become a feature in itself called "MY_ENCRYPTION_SIMPLE_PASSWD (without the signing).

                          S Offline
                          S Offline
                          sineverba
                          Hardware Contributor
                          wrote on last edited by
                          #12

                          @alowhum

                          I did have same issues, with new version, when was in testing stage.

                          Try at the top of sketch add these:

                          #define MY_DISABLE_SIGNAL_REPORT
                          #define MY_SPLASH_SCREEN_DISABLED
                          

                          You save a lot of space. All my nodes are on ATMEGA328 and no space issues. Max node with signing + encryption + relay + temp uses 67% of space

                          AnticimexA 2 Replies Last reply
                          0
                          • S sineverba

                            @alowhum

                            I did have same issues, with new version, when was in testing stage.

                            Try at the top of sketch add these:

                            #define MY_DISABLE_SIGNAL_REPORT
                            #define MY_SPLASH_SCREEN_DISABLED
                            

                            You save a lot of space. All my nodes are on ATMEGA328 and no space issues. Max node with signing + encryption + relay + temp uses 67% of space

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

                            @sineverba there is also a documentation section on this: https://www.mysensors.org/apidocs/group__memorysavings.html

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

                            1 Reply Last reply
                            0
                            • S sineverba

                              @alowhum

                              I did have same issues, with new version, when was in testing stage.

                              Try at the top of sketch add these:

                              #define MY_DISABLE_SIGNAL_REPORT
                              #define MY_SPLASH_SCREEN_DISABLED
                              

                              You save a lot of space. All my nodes are on ATMEGA328 and no space issues. Max node with signing + encryption + relay + temp uses 67% of space

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

                              @sineverba I also believe the signal report flag is reversed nowadays, and is an opt-in feature and not an opt-out feature, using MY_SIGNAL_REPORT_ENABLED which defaults to "off". Hence it is not listed in the memory savings section of the documentation, but the documentation of MY_SIGNAL_REPORT_ENABLED does warn that it adds about 1k of flash use.

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

                              S 1 Reply Last reply
                              0
                              • AnticimexA Anticimex

                                @sineverba I also believe the signal report flag is reversed nowadays, and is an opt-in feature and not an opt-out feature, using MY_SIGNAL_REPORT_ENABLED which defaults to "off". Hence it is not listed in the memory savings section of the documentation, but the documentation of MY_SIGNAL_REPORT_ENABLED does warn that it adds about 1k of flash use.

                                S Offline
                                S Offline
                                sineverba
                                Hardware Contributor
                                wrote on last edited by
                                #15

                                @anticimex Ah, I did not know, cause I'm in 2.2.0 rc2 (when something works... don't touch it! :D )

                                1 Reply Last reply
                                0
                                • alowhumA alowhum

                                  I can't ask for much more than that. Thanks man!

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

                                  @alowhum check the development branch. Simple password system has been reworked. Also, documentation is updated.

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

                                  alowhumA 1 Reply Last reply
                                  1
                                  • AnticimexA Anticimex

                                    @alowhum check the development branch. Simple password system has been reworked. Also, documentation is updated.

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

                                    @anticimex Awesome!

                                    So I had a look at the new code, and is this a fair summary?:

                                    • Simple encryption and simple signing are now two separate functions you can call at the top of your script by adding a line with a password: MY_ENCRYPTION_SIMPLE_PASSWD and MY_SIGNING_SIMPLE_PASSWD.
                                    • You can also just put "MY_SECURITY_SIMPLE_PASSWD" at the top of your script, and that will do both in one go. This used to be called the MY_SIGNING_SIMPLE_PASSWD option, which also did both.
                                    MY_SIGNING_SIMPLE_PASSWD is now
                                    called MY_SECURITY_SIMPLE_PASSWD.
                                    MY_SIGNING_SIMPLE_PASSWD only affects signing,
                                    and a new flag, MY_ENCRYPTION_SIMPLE_PASSWD
                                    only affects encryption.
                                    MY_SECURITY_SIMPLE_PASSWD enable both these flags.
                                    

                                    This is simply wonderful.

                                    • More choice and flexibility for the end user.
                                    • Get some simple security on your existing Arduino hardware.

                                    Thank you so much for this.

                                    AnticimexA D 2 Replies Last reply
                                    1
                                    • alowhumA alowhum

                                      @anticimex Awesome!

                                      So I had a look at the new code, and is this a fair summary?:

                                      • Simple encryption and simple signing are now two separate functions you can call at the top of your script by adding a line with a password: MY_ENCRYPTION_SIMPLE_PASSWD and MY_SIGNING_SIMPLE_PASSWD.
                                      • You can also just put "MY_SECURITY_SIMPLE_PASSWD" at the top of your script, and that will do both in one go. This used to be called the MY_SIGNING_SIMPLE_PASSWD option, which also did both.
                                      MY_SIGNING_SIMPLE_PASSWD is now
                                      called MY_SECURITY_SIMPLE_PASSWD.
                                      MY_SIGNING_SIMPLE_PASSWD only affects signing,
                                      and a new flag, MY_ENCRYPTION_SIMPLE_PASSWD
                                      only affects encryption.
                                      MY_SECURITY_SIMPLE_PASSWD enable both these flags.
                                      

                                      This is simply wonderful.

                                      • More choice and flexibility for the end user.
                                      • Get some simple security on your existing Arduino hardware.

                                      Thank you so much for this.

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

                                      @alowhum you are welcome. Just remember that simple in this context also mean weak. Storing the secrets in the sketch is a huge security implication on targets that does not support readout protection. Atmga328p among others.

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

                                      alowhumA 1 Reply Last reply
                                      0
                                      • AnticimexA Anticimex

                                        @alowhum you are welcome. Just remember that simple in this context also mean weak. Storing the secrets in the sketch is a huge security implication on targets that does not support readout protection. Atmga328p among others.

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

                                        @anticimex I understand. But if my neighbour has access to the nodes inside my house, then I have a bigger security problem :-)

                                        AnticimexA 1 Reply Last reply
                                        0
                                        • alowhumA alowhum

                                          @anticimex I understand. But if my neighbour has access to the nodes inside my house, then I have a bigger security problem :-)

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

                                          @alowhum right, but if you update your sketches OTA, he can potentially sniff your key OTA as well and then he does not need to enter your house ;)

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

                                          alowhumA alexsh1A 2 Replies Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          10

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 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