Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Derive key with PBKDF2 for HMAC? #24

Open
claq2 opened this issue Jan 30, 2016 · 2 comments
Open

Derive key with PBKDF2 for HMAC? #24

claq2 opened this issue Jan 30, 2016 · 2 comments

Comments

@claq2
Copy link

claq2 commented Jan 30, 2016

Do browsers really support generating HMAC keys with PBKDF2? Both Chrome and Firefox seem to complain when I pass {name:"HMAC"} to deriveKey in the 3rd parameter. I can't seem to find a definitive answer anywhere.

@JustinDrake
Copy link

JustinDrake commented Feb 17, 2017

Same here. The error I get on Chrome is

HmacImportParams: hash: Missing or not an AlgorithmIdentifier

On Safari:

NotSupportedError (DOM Exception 9): The operation is not supported.

On Firefox the promise hangs.

@ehuggett
Copy link

This works for me*, does it help? (or have i misunderstood the issue)

    const pwdKey = await window.crypto.subtle.importKey(
      'raw',
      encoder.encode(password),
      { name: 'PBKDF2' },
      false,
      ['deriveKey']
    );
    const newAuthKey = await window.crypto.subtle.deriveKey(
      {
        name: 'PBKDF2',
        salt: encoder.encode(file.url),
        iterations: 100,
        hash: 'SHA-256'
      },
      pwdKey,
      {
        name: 'HMAC',
        hash: 'SHA-256'
      },
      true,
      ['sign']
    );

context: https://github.com/mozilla/send/blob/9410defab6156d29bb705f73aefbd09ec588678e/app/fileSender.js#L239-L260

*Firefox ESR 52.4.0 and Firefox Developer Edition 57.0b10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants