Encryption on puckjs

Posted on
  • Hi there, I see that AES and SHA1 functions aren't available on the Puck.js, I do see that the source code for the puckjs build says that it is built with the Crypto library. Is encryption either AES or Sha1 available on the puck.js?

  • Hi,

    There's definitely SHA1 in Puck.js (at least on recent firmware) - you just use require("crypto").SHA1("your data"), however there was no AES built in.

    Looking at it, there is space for it so I just added it. If you use one of the latest 'travis' builds from http://www.espruino.com/binaries/travis/­master/ then it should now have require("crypto").AES in (or it'll be in the 1v97 release).

  • Wow, thanks a lot this is great If you don't mind me asking what are the steps you recommend to add/remove features on the puck,

  • Well, first you need to be able to build it yourself, using the info here: https://github.com/espruino/Espruino/blo­b/master/README_Building.md

    But then if you look at this bit of the Puck's board file: https://github.com/espruino/Espruino/blo­b/master/boards/PUCKJS.py#L30

    You'll see a bunch of libraries - you can comment/uncomment those (or look in other boards in the directory to find other libraries you can add).

    You can add your own too - there's some info here: http://www.espruino.com/Extending+Esprui­no+1

  • Hi there thanks a lot I've been able to make quite a bit of progress in my project. I am not sure what is causing it but flashing my builds using the nrftool app results in the Puck to just display a solid red light upon resetting, and I am unable to see the device. I am building the device from source with the command

    DFU_UPDATE_BUILD=1 BOARD=PUCKJS RELEASE make

    I am not quite sure what this means and was wondering if I am building it right.

  • That all looks fine - did you flash the zip that's created with the steps from http://www.espruino.com/Puck.js#firmware­-updates ?

    Specifically the very last step with the button that clears out any saved JS.

    You mentioned nrftool - did you connect directly to the board via SWD? If so you'll need to build without DFU_UPDATE_BUILD=1 and flash the resulting hex (as that'll include the bootloader)

  • Hi Gordon,

    So here are my specific steps. I am on Ubuntu 18.04, using arm-gcc version gcc-arm-none-eabi-7-2017-q4-major.

    1. I cloned https://github.com/espruino/Espruino and ran

      source scripts/provision.sh PUCKJS
      
    2. then

      DFU_UPDATE_BUILD=1 RELEASE=1  BOARD=PUCKJS make
      
    3. This spat out an 'espruino_1v97.5_puckjs.zip' which i transferred to my phone and programmed according to the instructions using nrftoolbox app on my phone

    4. I reset the device by removing the battery then holding the button while reinserting it. I keep it held down while the light is green.

    However at this step the light turns red and stays a solid red instead of blinking all 3 leds then blinking red for a few times.

    Note that I have done this exact method with the .zip from http://www.espruino.com/binaries/travis/­master/
    and the whole process works as expected, it seems to fail with the .zip file I make myself. Even without any modifications to the code I took directly off github.

  • That really is strange. What you're doing looks spot on - however I'm on ARM GCC 5.4.1 20160919 and it's possible that the newer GCC causes problems somehow.

    If you uninstall ARM GCC 7 or just take it out of the path then I believe the provision script will install the GCC that we generally use, which will hopefully provide better results.

  • Thanks I got it working, The problem was the new GCC version. I guess for the first time in my life it WAS actually the compiler's fault.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Encryption on puckjs

Posted by Avatar for Peterino @Peterino

Actions