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

🐛 HashAlgorithm shape incorrect #557

Open
4 tasks done
dominictobias opened this issue Dec 12, 2024 · 0 comments
Open
4 tasks done

🐛 HashAlgorithm shape incorrect #557

dominictobias opened this issue Dec 12, 2024 · 0 comments

Comments

@dominictobias
Copy link

dominictobias commented Dec 12, 2024

What's happening?

https://developer.mozilla.org/en-US/docs/Web/API/EcdsaParams states that hash can only be a string. But it can also be an object like this:

{
   name: HashAlgorithm
}

You can see this in W3C and Typescript defs:

interface Algorithm {
    name: string;
}

type AlgorithmIdentifier = Algorithm | string;

type HashAlgorithmIdentifier = AlgorithmIdentifier;

interface EcdsaParams extends Algorithm {
    hash: HashAlgorithmIdentifier;
}

W3C docs: https://www.w3.org/TR/WebCryptoAPI/#EcdsaParams-dictionary

dictionary EcdsaParams : Algorithm {
  // The hash algorithm to use
  required HashAlgorithmIdentifier hash;
};

typedtypedef (object or DOMString) AlgorithmIdentifier;

typedef AlgorithmIdentifier HashAlgorithmIdentifier;

dictionary Algorithm {
  required DOMString name;
};

The issue is that code in the wild uses that structure:

const webCryptoSig = await window.crypto.subtle.sign(
    {
        name: 'ECDSA',
        hash: {
            name: 'SHA-256',
        },
    },
    priv,
    buffer
)

Meaning that this lib is not a straight replacement for those libs right now, which is a shame! Unless the underlying code accepts it and the TS defs are simply incorrect.

Reproducible Code

N/A

Relevant log output

N/A

Device

N/A

QuickCrypto Version

0.7.9

Can you reproduce this issue in the QuickCrypto Example app?

Yes, I can reproduce the same issue in the Example app here

Additional information

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

1 participant