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

SubtleCrypto.deriveBits fails with P-384 keys #14765

Closed
diachedelic opened this issue Jun 1, 2022 · 5 comments
Closed

SubtleCrypto.deriveBits fails with P-384 keys #14765

diachedelic opened this issue Jun 1, 2022 · 5 comments
Labels
bug Something isn't working correctly ext/crypto related to the ext/crypto crate web related to Web APIs

Comments

@diachedelic
Copy link
Contributor

The following script fails with an "Unsupported namedCurve" error. It works fine if the P-384 is changed to P-256.

function generate_keypair() {
    return crypto.subtle.generateKey(
        {name: "ECDH", namedCurve: "P-384"},
        true,
        ["deriveBits"]
    );
}

Promise.all([
    generate_keypair(),
    generate_keypair()
]).then(function ([alice, bob]) {
    return crypto.subtle.deriveBits(
        {name: "ECDH", public: bob.publicKey},
        alice.privateKey,
        256
    );
}).then(
    console.log
);

It appears that the upstream fix mentioned in this TODO comment has just landed, meaning that it should be possible to make SubtleCrypto.deriveBits work with P-384 keys.

@lucacasonato lucacasonato added bug Something isn't working correctly web related to Web APIs ext/crypto related to the ext/crypto crate labels Jun 3, 2022
@diachedelic
Copy link
Contributor Author

Version 0.11.0 of the p384 crate was released a few days ago, and it seems to contain the functionality we require. However, in bumping p384 from v0.8.0 to v0.11.0 I got some Cargo version conflicts. To resolve these conflicts, I upgraded some other RustCrypto crates:

  • elliptic-curve from 0.10.6 to 0.11.0 (0.12.0 is the latest)
  • p256 from 0.9.0 to 0.11.0
  • rsa from 0.5.0 to 0.6.1
  • spki from 0.4.1 to 0.6.0

Unfortunately, this broke the build (https://gist.github.com/diachedelic/a760e057d032dcc53765dda73adf863f). At this point, I realised I was out of my depth.

@diachedelic
Copy link
Contributor Author

I also noticed this comment

Shamelessly copied from pkcs8 crate and modified so as to not require Arithmetic trait currently missing from p384

which looks like it wants to be addressed alongside this issue.

@littledivy
Copy link
Member

Version 0.11.0 of the p384 crate was released a few days ago, and it seems to contain the functionality we require.

There is a PR for upgrading all the webcrypto deps: #14452 This should be unblocked after that.

@diachedelic
Copy link
Contributor Author

Legend!

@diachedelic
Copy link
Contributor Author

Duplicate of #13451.

@diachedelic diachedelic closed this as not planned Won't fix, can't repro, duplicate, stale Jun 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly ext/crypto related to the ext/crypto crate web related to Web APIs
Projects
None yet
Development

No branches or pull requests

3 participants