webcrypto-liner icon indicating copy to clipboard operation
webcrypto-liner copied to clipboard

Error: Unsupported algorithm 'hmac' -- Safari

Open lightninglu10 opened this issue 7 years ago • 4 comments

Hey guys, I'm trying to use this package or webcrypto-shim to fix Safari's webcrypto package.

I'm getting this error though:

Error: Unsupported algorithm 'hmac'

I've included asymcrypto and elliptic in my html:

    <script src="%PUBLIC_URL%/webcrypto-liner.shim.js"></script>
    <script src="%PUBLIC_URL%/asmcrypto.min.js"></script>
    <script src="%PUBLIC_URL%/elliptic.min.js"></script>

Any advice here?

lightninglu10 avatar Sep 06 '17 00:09 lightninglu10

We did not add HMAC to liner yet.

You can see the algorithms we did add support for in the README.

asymcrypto.js does support HMAC so you could easily do a PR that added it to liner.

You would basically use the SHA2 logic as the prototype

rmhrisk avatar Sep 06 '17 01:09 rmhrisk

For hmac, asymcrypto supports

HMAC-SHA1 HMAC-SHA256 HMAC-SHA512

but in webcryptocore, there's only algorithm name Hmac.

Looking at what you guys did for sha2, how would it know which one to use?

Or can I use any of the sha schemes?

lightninglu10 avatar Sep 06 '17 01:09 lightninglu10

Webcrypto core is a generic layer we use for input validation in our various WebCrypto libraries.

You would need to add support for HMAC-SHA256 (and maybe HMAC-SHA512) to liner for it to work.

You can use the existing SHA256 code as a guide.

@microshine is busy with another work right now so we cant commit to doing it ourselves in the near term but if you or someone else wanted to add these we would be open to a solid PR.

rmhrisk avatar Sep 06 '17 02:09 rmhrisk

It'll be helpful if somebody wants to make PR

HMAC examples W3 HMAC specification - webcrypto-core checks incoming data

  1. Create HmacCryptoKey and HmacCrypto, similar to RSA implementation
  2. Add HmacCrypto to SubtleCrypto
  3. Make tests

microshine avatar Sep 06 '17 05:09 microshine