Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    How to protect my main.py

    Scheduled Pinned Locked Moved Discussion
    lopywipysipysecurity
    8 Posts 5 Posters 2.5k Views 5 Watching
    Loading More Posts
    • 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.
    • I Offline
      iotmaker
      last edited by

      if i were to release a product with a pycom board. How can i make sure no body looks at the main.py file?

      robert-hhR L J 3 Replies Last reply Reply Quote 1
      • robert-hhR Offline
        robert-hh @iotmaker
        last edited by

        @iotmaker A simple method would be to make main.py very primitive and put the code in some other script, let's call it myapp.py, which will be embedded as frozen bytecode. main.py would then simply consist of:
        import myapp
        Frozen bytecode would require you to build your own image, which is not that hard. And frozen bytecode is like compiled code. Text and constants are visible in clear, and it is possible to create wome kind of decoder. But it is some barrier.
        Putting main.py literally is not reccomended.

        1 Reply Last reply Reply Quote 2
        • L Offline
          livius @iotmaker
          last edited by

          @iotmaker
          @robert-hh show some first steap in protection
          i wait for bigger steap to be finalized - look here "Encryption of Python scripts to protect code"
          https://forum.pycom.io/topic/433/features-wish-list

          think about people first, then computers

          robert-hhR 1 Reply Last reply Reply Quote 0
          • J Offline
            jmarcelino @iotmaker
            last edited by jmarcelino

            Security for the 4MB modules (OEM, FiPy, etc) with the external SPI pSRAM (which conveniently comes in a SOP-8 package) will be quite interesting.

            1 Reply Last reply Reply Quote 0
            • robert-hhR Offline
              robert-hh @livius
              last edited by

              @livius besides decryption on the fly, which is a task of the compiler/parser, then the protection and management of the key is the challenge.

              J 1 Reply Last reply Reply Quote 0
              • J Offline
                jmarcelino @robert-hh
                last edited by

                @robert-hh
                The ESP32 does have Flash encryption, the key is then stored in the efuses and is read protected. At ESP-IDF level it's already documented: http://esp-idf.readthedocs.io/en/latest/security/flash-encryption.html

                This doesn't need support from the compiler but looks difficult to reconcile this with the current flexible, change firmware at any time, development system though.

                robert-hhR 1 Reply Last reply Reply Quote 0
                • robert-hhR Offline
                  robert-hh @jmarcelino
                  last edited by

                  @jmarcelino if that is built in to the low level esp.read and esp.write to flash, then it may be transparent, covering anything in flash, like binary code, frozen bytecode and file system. It would then protect against raw readout of flash bypassing the esp.

                  1 Reply Last reply Reply Quote 0
                  • R Offline
                    ronald gevern Banned
                    last edited by

                    This post is deleted!
                    1 Reply Last reply Reply Quote 0

                    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                    With your input, this post could be even better 💗

                    Register Login
                    • 1 / 1
                    • First post
                      Last post

                    Pycom on Twitter

                    Pycom