SHA256/512 Availability

Posted on
  • SHA1 is available in the emulator, but SHA256 and SHA512 (and SHA384 and SHA224) are not.

    From looking at:

    https://github.com/espruino/Espruino/blo­b/3875b8d3916399196f413074f6533181387605­34/libs/crypto/jswrap_crypto.c#L143

    it looks like the Bangle is just getting the JS version of SHA1.

    What are the chances of getting SHA256 and SHA512? I'm looking into developing a 2FA app for my Bangle 2 and would like to support all the options.

  • Thanks - I've just included this. They'll be in builds from now on (and when I update the emulator).

    Bangle.js 1 was a bit tight on flash memory which is why these weren't included, but we've got a lot more on Bangle.js 2 so it's not such a big deal

  • Fabulous! Thanks for that.

    I was thinking I'd have to write my own for a bit there. Built-in support will make it a lot easier.

    Next is how to manage the tokens using a phone (Bluetooth?). If necessary I'll start a new thread once I've read some more...

  • Just wondering: I've updated my watch to 2v10.236 from the 2v10.219 I'm pretty sure it shipped with. Neither of these firmwares appear to have SHA256/512 support, and the SHA1 is slow enough I'm certain it's the JavaScript version.

    Both of them are more recent than the 2v10.187 that's in the current emulator, which does support SHA256/512.

    Should the current watch firmware have this support?

  • Should the current watch firmware have this support?

    Should do... It's in the build, and I just ran require("crypto").SHA256([1,2,3]) on a Bangle.js 2 with 2v10.236 and it works great

  • OK, this is weird. My Bangle 2 has my app loaded via the App Loader. If I connect the IDE to the Bangle and run "authentiwatch.app.js" from the device storage, then the SHA256/512 functions are missing:

    c=require("crypto")
    ={
      SHA1: function (b) { ... }
     }
    >c.SHA512
    =undefined
    >c.SHA1
    =function (b) { ... }
    

    However, if I click the "Send to Espruino" with RAM selected, the SHA256/512 functions suddenly exist!

    c=require("crypto")
    =function () { [native code] }
    >c.SHA512
    =function () { [native code] }
    >c.SHA1
    =function () { [native code] }
    
  • Ohh, interesting - thanks! I bet the BangleApps loader thinks crypto isn't installed and then adds the JS polyfill, but that overwrites the one on the device. I'll look into that.

  • Ok, should now be fixed in the development app loader - next update it'll be fixed in the main one https://espruino.github.io/BangleApps/

  • Thanks, I'll give that a go tonight.

  • Confirmed fixed - thanks again!

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

SHA256/512 Availability

Posted by Avatar for andrewg_oz @andrewg_oz

Actions